60

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.

2
  • I was on a client's server and in a pinch so I ran a mysqldump and imported the return into pma on MY server.
    – Jacksonkr
    Commented Dec 14, 2017 at 17:16
  • In my case the folder name is: /var/lib/php/sessions Commented Apr 14, 2022 at 22:20

20 Answers 20

95

Problem usually lies on your browser end.

You need to flush your browser cache, delete the cookies for the server/host and then retry loading phpMyAdmin.

If you want to go all out, clear out the session folder on the server as well.

One possible reason for this is a session data mismatch between the browser and the webserver causing it to not be able to pull out the required session info and dumping this error dialogue on your lap.

7
  • 2
    Well, in my case, i have no 'tmp' directory on the host, where the Apache is storing the session data. Commented Feb 13, 2013 at 6:21
  • 1
    hey @shasi - do a <? phpinfo(); ?> and look for session.save_path. Commented Nov 25, 2014 at 19:26
  • I had to set my session folder to 777 sudo chmod 777 -R /var/lib/php5 as well as clearing my cache ctrl + F5
    – Edward
    Commented Sep 4, 2015 at 11:06
  • This answer was most of the solution in my case. I had a separate phpmyadmin open. (I wanted 2 windows, 1 for local and 1 for remote). By closing one window AND clearing the browser cache, the error went away. Commented Mar 14, 2016 at 9:07
  • this method didn't work for me, I also tried to remove some unnecessary .zip file from file manager but still the same error Commented Mar 2, 2019 at 16:31
69

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.

1
  • This is good for an instant/temporary fix. Using 777 privilege is overkill. This answer just debugs that "maybe you just don't have enough permissions" and you can try it by doing sudo chmod 777 /var/lib/php/session/. Commented Jan 21, 2019 at 3:10
11

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.

2
  • This is what I had to do after ensuring the above recommendations were followed. On my EC2 server, somehow my /var/lib/php/session directory ownership was set to the incorrect user:group.
    – JonnyB
    Commented Mar 25, 2014 at 3:56
  • This answer worked for me. They were owned by Apache but I was using nginx.
    – slick1537
    Commented Nov 26, 2014 at 15:05
10

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
5
  • Maybe better putting the apache into the right group. Commented Jun 19, 2019 at 14:30
  • I think this is better solution
    – Jigar7521
    Commented Jun 24, 2019 at 9:20
  • 1
    Great answer, 777 will leave the doors open for the bad guys to mess with your system if they get some type of leverage, stay away unless working locally...
    – misterzik
    Commented Apr 24, 2021 at 19:45
  • I think it should be www-data Commented Apr 14, 2022 at 22:00
  • changing ownership to Apache (or nginx) is EQUIVALENT to 777... they === wide open permissions to the world... this problem likely arose from replacing apache with nginx... chgrp -R nginx /var/lib/php/session worked for me (it was grp = apache)... i did not have to change ownership or permissions... however group writable as nginx is still equivalent wide open to the world
    – aequalsb
    Commented Feb 17, 2023 at 16:34
8

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]

4

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

1
  • 2
    Firefox - Clear cache = CRTL+F5
    – RiggsFolly
    Commented Feb 21, 2014 at 0:59
3

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

0
3

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> -

0
2

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
2

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

1

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. :(

1

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

TH

0

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

It worked !

0

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.

0

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

0

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

0

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_

0

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.

0

if you checked your browser and doesn't problem so check these commands on the server side :

based on session.save_path in php.ini file, check is exists session directory (default path is : "/var/lib/php/session") so if path isn't exists, make it.
now may need to either change ownership of the directory, e.g (change: user:group based your system)

sudo chown user:group /var/lib/php/session

then give permission to session path:

sudo chmod 0777 /var/lib/php/session

now refresh your browser

0

For Ubuntu:

In my case the error specify where is the issue. So I just run this code and it is fixed.

sudo chmod 777 /opt/lampp/temp

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.