Solved

php sessions are not persistent.

Posted on 2016-10-04
8
33 Views
Last Modified: 2016-10-12
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.
0
Comment
Question by:Ray
  • 4
  • 3
8 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 41828570
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.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 41828577
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:
https://www.experts-exchange.com/articles/11909/PHP-Sessions-Simpler-Than-You-May-Think.html
0
 

Author Comment

by:Ray
ID: 41828610
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.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 41828660
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
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:Ray
ID: 41828697
Apache/2.2.15 (CentOS)
php version 5.3
session.pdf
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 41828827
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!
0
 

Author Comment

by:Ray
ID: 41840251
Ray - thanks for your help!  We upgraded and sessions are working now!
1
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 41840297
Gr8 - glad that helped!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now