[php] Cannot start session without errors in phpMyAdmin

I get the below error when pointing browser to phpMyAdmin

Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly.

I have checked everything and can't seem to figure out what the problem is.

In my php.ini file I have:

session.save_path = "/var/lib/php/session"

Permissions:

drwxr-xr-x  2 root apache 4096 Feb 16 04:47 session

Nothing seems to work. Even changing permission on session directory to 777.

This question is related to php session phpmyadmin

The answer is


I cleared browser cache. Created session folder as listed in phpinfo.php.

It worked !


Problem I found in Windows server 2016 was that the permissions were wrong on the temp directory used by PHP. I added IUSR.


I worked on this same problem for a full day. The answer for me was to simply clear my browser's cache. Too bad, I had already reinstalled the webserver/phpmyadmin 3 times. :(


I recently had this very same problem. It was resolved by truncating the temp directory where php stores its session data.

ie for a Unix OS: OP ref. file (this temp directory will differ for your OS)

find /var/lib/php/session -type f -delete

After truncating the directory I was able to start phpmyadmin without issue. I hope this helps others with the same problem if changing ownership and/or permissions fail.


Ok,

I'm using windows 7 ultimate and WAMP 2.4 server The tmp folder was missing, so I created one and this solved my problem. Check the php.ini file for the correct path: session.save_path


There appears to be two common causes for this error, one is to do with the server configuration and the session.save_path and the other is the browser cache.

If you encounter this error try using a different browser or machine before you attempt to alter your Apache and PHP configurations on the server!

Note that clearing the Cookies for the server is not enough, you need to clear the cache.

In Firefox clearing all history and cookies is easy, but you may not want to get rid of everything. Clearing the cache is hidden away in Firefox:

Tools > Options > Advanced > Network: Cached Web Content - Clear Now


Login fails if session folder in not writeable. To check that, create a PHP file in your web directory with:

<?php
$sessionPath = 'undefined';

if (!($sessionPath = ini_get('session.save_path'))) {
    $sessionPath = isset($_ENV['TMP']) ? $_ENV['TMP'] : sys_get_temp_dir();
}

if (!is_writeable($sessionPath)) {
    echo 'Session directory "'. $sessionPath . '"" is not writeable';
} else {
    echo 'Session directory: "' . $sessionPath . '" is writeable';
}

If session folder is not writeable do either

sudo setfacl -R -m u:www-data:rwx <session directory> or chmod 777 <session directory> -


For Xampp, Deleting temp flies from the 'root' folder works for me.

TH


STOP 777!


If you use nginx (like me), just change the ownership of the folders under /var/lib/php/ from apache to nginx:

[root@centos ~]# cd /var/lib/php/
[root@centos php]# ll
total 12
drwxrwx---. 2 root apache 4096 Jan 30 16:23 opcache
drwxrwx---. 2 root apache 4096 Feb  5 20:56 session
drwxrwx---. 2 root apache 4096 Jan 30 16:23 wsdlcache

[root@centos php]# chown -R :nginx opcache/
[root@centos php]# chown -R :nginx session/
[root@centos php]# chown -R :nginx wsdlcache/
[root@centos php]# ll
total 12
drwxrwx---. 2 root nginx 4096 Jan 30 16:23 opcache
drwxrwx---. 2 root nginx 4096 Feb  5 20:56 session
drwxrwx---. 2 root nginx 4096 Jan 30 16:23 wsdlcache

And also for the folders under /var/lib/phpMyAdmin/:

[root@centos php]# cd /var/lib/phpMyAdmin
[root@centos phpMyAdmin]# ll
total 12
drwxr-x---. 2 apache apache 4096 Dec 23 20:29 config
drwxr-x---. 2 apache apache 4096 Dec 23 20:29 save
drwxr-x---. 2 apache apache 4096 Dec 23 20:29 upload

[root@centos phpMyAdmin]# chown -R nginx:nginx config/
[root@centos phpMyAdmin]# chown -R nginx:nginx save/
[root@centos phpMyAdmin]# chown -R nginx:nginx upload/
[root@centos phpMyAdmin]# ll
total 12
drwxr-x---. 2 nginx nginx 4096 Dec 23 20:29 config
drwxr-x---. 2 nginx nginx 4096 Dec 23 20:29 save
drwxr-x---. 2 nginx nginx 4096 Dec 23 20:29 upload

In my case it was the wrong ownership for /var/lib/php/session. I changed that to the Apache user and group (the user and group that the webserver runs as) and all was well.


This is sometimes due to an invalid session key. If using XAMPP, what worked for me was opening the temp folder in XAMPP xampp/temp then deleting the session files starting with sess_


First: if not session dir (in my case it was)

sudo mkdir /var/lib/php/session

Second: set privilege for session dir

sudo chmod 777 /var/lib/php/session

Knowing this thread is marked as solved, it shows up early on Google Search for the given term. So I thought it might be useful to mention another reason that can lead to this error.

If you enabled "safe/secure cookies", that has to be disabled for phpMyAdmin as it wont work with them being activated. So make sure you have nothing like:

Header set Set-Cookie HttpOnly;Secure

in your config.


The problem can be due to file and folder permissions; You can try changing the folder permissions:

sudo chmod 777 /var/lib/php/session/

This will set full read/write permissions on the PHP sessions folder.

Note: the php/session/ folder may be in a different location on some servers. Check your php.ini for your session path.


Set the session.save_path in your php.ini. Make sure that you are using an existing directory.

If still you found any issue then give write & execution permission to that folder for the user by which you are going to use that folder.[This is specially used in case of IIS]


The problem can also be that you have a wrong session.save_handler value in your php.ini. I got this error when I changed it to memcached, and worked again when changing back to files


In my case, problem was due to low disk space. I want to mention it for other users like me :)


Examples related to php

I am receiving warning in Facebook Application using PHP SDK Pass PDO prepared statement to variables Parse error: syntax error, unexpected [ Preg_match backtrack error Removing "http://" from a string How do I hide the PHP explode delimiter from submitted form results? Problems with installation of Google App Engine SDK for php in OS X Laravel 4 with Sentry 2 add user to a group on Registration php & mysql query not echoing in html with tags? How do I show a message in the foreach loop?

Examples related to session

What is the best way to manage a user's session in React? Spring Boot Java Config Set Session Timeout PHP Unset Session Variable How to kill all active and inactive oracle sessions for user Difference between request.getSession() and request.getSession(true) PHP - Session destroy after closing browser Get Current Session Value in JavaScript? Invalidating JSON Web Tokens How to fix org.hibernate.LazyInitializationException - could not initialize proxy - no Session How can I get session id in php and show it?

Examples related to phpmyadmin

phpMyAdmin on MySQL 8.0 phpmyadmin - count(): Parameter must be an array or an object that implements Countable Error loading MySQLdb Module 'Did you install mysqlclient or MySQL-python?' phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO) phpMyAdmin access denied for user 'root'@'localhost' (using password: NO) mysqli_real_connect(): (HY000/2002): No such file or directory How to create a foreign key in phpmyadmin #1292 - Incorrect date value: '0000-00-00' MySQL error - #1932 - Table 'phpmyadmin.pma user config' doesn't exist in engine phpMyAdmin Error: The mbstring extension is missing. Please check your PHP configuration