homepage Welcome to WebmasterWorld Guest from 54.226.235.222
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Session cookie expiring too early
Readie




msg:4571569
 3:08 pm on May 7, 2013 (gmt 0)

Hey guys,

Got a bit of an issue on the system I'm developing, with session cookies being prematurely dropped, despite being explicitly told to last for 12 hours.

Other cookies I'm setting are lasting their designated 14 days.

The browser in question is Firefox (internal system, we're all using FF 19+)

In the base include file, I have the following lines to initialize the session:
if(php_sapi_name() !== 'cli') {
if(!isset($_SESSION)) {
session_set_cookie_params(43200);
session_start();
}
}
[uk3.php.net ]

And in the Web Developer Toolbar cookie viewer it is being shown as:
Name  PHPSESSID 
Valued 9hgs8ekjo2g2oeen0pvq2a630
Host [[HIDDEN]].co.uk
Path /
Expires Wed, 08 May 2013 03:20:34 GMT
Secure No
HttpOnly No

Note that the "Expires" there is 12 hours after the last time I performed an action on the site

I've dug through the about:config settings, and made the following changes, which when rolled out fixed it for several users (myself included), but several people are still experiencing the issue:
network.cookie.alwaysAcceptSessionCookies;true
privacy.clearOnShutdown.cookies;false
services.sync.prefs.sync.privacy.clearOnShutdown.cookies;false

And despite much Googling and quizzing my colleagues, I'm all out of ideas for what to do.

So, I'm *really* hoping one of you guys might have some insight as to why this is happening, and how to go about fixing it.

Thanks in advance,

Mike

 

lucy24




msg:4571650
 7:51 pm on May 7, 2013 (gmt 0)

session cookies being prematurely dropped, despite being explicitly told to last for 12 hours

It's either a session cookie or a cookie with an explicit duration time. Which is it?

I've come to grief a few times through giving times in minutes when the system expected seconds or vice versa ("Whoops! Why is this cookie set to expire in 2028?")

Readie




msg:4571659
 8:35 pm on May 7, 2013 (gmt 0)

I used the wrong terminology there, sorry - I mean the cookie with a reference to the PHP session is being dropped prematurely.

DrDoc




msg:4571696
 11:07 pm on May 7, 2013 (gmt 0)

Is session_set_cookie_params always called, whether the session already exists or not, prior to calling session_start?

Readie




msg:4571761
 7:06 am on May 8, 2013 (gmt 0)

Yes

Readie




msg:4575213
 11:34 am on May 18, 2013 (gmt 0)

Just to let peeps know: It turned out that the php.ini setting session.gc_maxlifetime was set really low. Problem solved, users are now finding other things to complain about :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved