2

First, I have already looked at rciiipo's post from 2011. My problem don't seem to be fixed with the answers provided, and I have a few other inputs.

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.
Also ensure that cookies are enabled in your browser.

1) Session variables don't work with any php file. I am little unsure if it is related, but i believe the one problem causes the other.

This code below should display "teddy" when i refresh the webpage:

<?php
session_start();

$username = $_SESSION['username'];
if(isset($_SESSION['logged']) && $_SESSION['logged']=='yes') {
    echo "$username";
}   

$_SESSION['username']='Teddy';
$_SESSION['logged']='yes';
?>

My php.ini file:

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

Permissions:

drwxr-xr-t  4 root www-data 4096 Sep  1 08:40 php5
  |
  -- drwxr-xr-x  2 root www-data 4096 Sep  1 08:40 session

I think the problem can be fixed if I only get $_SESSION variables to work in php.

Community
  • 1
  • 1
Mattis Asp
  • 993
  • 3
  • 14
  • 29
  • 1
    it looks like you have wrong permission for `/var/lib/php5/session` it should be `drwxrwxr-t` or `dr-xrwxr-t` (assuming `www-data` is the web server user). Write permission is required in the directory to save session data. – bansi Sep 01 '14 at 07:11
  • Yes, thats all it needed. Why is that? – Mattis Asp Sep 01 '14 at 07:16
  • PHP stores the session data to the session.save_path and as PHP is being executed by web server, it runs on the web server's user. That is why the web server user needs write permission to the folder. – bansi Sep 01 '14 at 07:24

1 Answers1

3

I agree with bansi:

it looks like you have wrong permission for /var/lib/php5/session it should be drwxrwxr-t or dr-xrwxr-t (assuming www-data is the web server user). Write permission is required in the directory to save session data.

Also, you should check the log files in /var/log/ of PHP (and maybe Apache as well) - they might give you some more details...

Community
  • 1
  • 1
Xenonite
  • 1,823
  • 4
  • 26
  • 39