php sessions are not persistent.

New install using Apache and Php.  Used ray_session_test.php script found here at Experts-exchange.  I can see where the session is being created on in /var/lib/php/session, but it's like the script can't find the session once it's been created.  I'm running the same script on a production server and it works fine, so this is not a php coding issue.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Ray PaseurConnect With a Mentor Commented:
PHP Version 5.3 is obsolete; don't use that.  Upgrade to one of the current versions shown on the PHP home page.

Maybe check permissions on the save path.  Nothing in there jumps out at me!
Dave BaldwinFixer of ProblemsCommented:
That's a very simple script.  Are you getting any error messages?  How is it not working?  Are you testing it using Chrome on 'localhost'?  If so, it may not be setting the session cookie.  Chrome doesn't set cookies on 'localhost' because it is not a unique address.  Switch to the IP address of the machine and try it.
Ray PaseurCommented:
PHP sessions use HTTP cookies.  If cookies are not accepted and returned the session cannot work correctly.  Try another browser and be sure that you can log into some other application such as Amazon or eBay.  Then close the browser (all windows) and restart the browser.  If you're still logged in to Amazon or eBay, the cookies are working OK, and the PHP session should work OK, too.

This might be helpful:
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

RayAuthor Commented:
Thanks.  Not using localhost and have tried several different browsers.

I've tested with the ray_session_test.php script and I can see the sessions files being created. When I click on the "increment this cheese", a new session id is created.  The increment stops at 2.   I've tested the script on another server and it works perfectly, so we can eliminate php syntax errors.   I'm guessing either a php.ini file setting or apache issue?

cookies are working.
Ray PaseurCommented:
Maybe try running phpinfo() and look for the configuration options associated with the session.  The save_path or cookie_path might be in play.

Here's a screen shot of my session installation.Session information from phpinfo() output
RayAuthor Commented:
Apache/2.2.15 (CentOS)
php version 5.3
RayAuthor Commented:
Ray - thanks for your help!  We upgraded and sessions are working now!
Ray PaseurCommented:
Gr8 - glad that helped!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.