Cesar Vieira
Cesar Vieira

Reputation: 21

My session variables are not being saved across multiple pages

I'm strugling with why the session is not being saved accross my webpages. I have used this same code on a previous server and works perfectly, but when I tried to install the app on this new server, the session variables are not beeing saved at all.

Every page that is loaded, it passes thourgh this loading function:

// Initialise session data
session_start();

// Dispatch the request 
$template = dispatchRequest();

// Output the response 
echo($template->getOutput());

// Finished 
exit;

Template is a function that loads the current page according to the action is being requested, for example, www.webpage.com/do-something, this will bring up the do-something page.

Here is part of my phpinfo output:

Session Support enabled 
Registered save handlers files user
Registered serializer handlers php php_binary

Directive Local Value Master Value 
session.auto_start Off Off 
session.bug_compat_42 Off Off 
session.bug_compat_warn On On 
session.cache_expire 180 180 
session.cache_limiter nocache nocache 
session.cookie_domainno value no value 
session.cookie_httponly Off Off 
session.cookie_lifetime 0 0 
session.cookie_path /tmp /tmp 
session.cookie_secure Off Off 
session.entropy_file no value no value 
session.entropy_length 0 0 
session.gc_divisor 1000 1000 
session.gc_maxlifetime 2700 2700 
session.gc_probability 1 1 
session.hash_bits_per_character 5 5 
session.hash_function 0 0 
session.name PHPSESSID PHPSESSID 
session.referer_check no value no value 
session.save_handler files files 
session.save_path /tmp /tmp 
session.serialize_handler php php 
session.use_cookies On On 
session.use_only_cookies Off Off 
session.use_trans_sid 0 0

Upvotes: 2

Views: 1462

Answers (2)

noel av
noel av

Reputation: 1

I did

chmod a+rwx /var/lib/php/session

and it worked for lighttpd.

Upvotes: 0

tradyblix
tradyblix

Reputation: 7569

If this is a new server maybe sessions aren't successfully written to the session folder, by default I think it saves it in /tmp but you may want to try setting a path in your php.ini like:

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

Apply proper write permissions to the folder and see if sessions are persisting across pages.

Upvotes: 2

Related Questions