troubleshooting Question

Session Vars not working after server migration

Avatar of feign3
feign3 asked on
PHPApache Web Server
4 Comments1 Solution469 ViewsLast Modified:
I just moved my site to a Linux VPS and am having an issue with Session variables. Session vars are not getting passed from page to page. I used the following simple test to check the setup:


<?php session_start();
$_SESSION['userid'] = "foo";
print "Session id is: " . session_id() . $_SESSION['userid'];
print "<a href=secondpage.php'> go to next page </a>";


<?php session_start();
print "Welcome" . $_SESSION['userid'] . "<br />";
print "You have got to page 2 with these information stored in the session: " . $_SESSION['userid'] . " and your session is still: " ;
echo session_id();

When testing this, I get a different Session ID on the second page and no 'userid' printed.
I have made several changes to my php.ini file including:

1. enabled register_globals
2. set session.save_path and confirmed the path exists and is writable

Here is my php.ini Session info:

Session Support  enabled  
Registered save handlers  files user mm  

Directive Local Value Master Value
session.auto_start Off Off
session.bug_compat_42 On On
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 100 100
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1 PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /home/mydomain/tmp/session_files /home/mydomain/tmp/session_files
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid Off Off

I'm not sure what else I could be missing.

Robin HickmottSoftware Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2006

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 4 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 4 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004