Forum Moderators: coopster

Message Too Old, No Replies

Sessions timing out.

Even when refreshing?

         

ahmedtheking

12:23 pm on Feb 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've noticed that my site's sessions are timing out (they're set to default of 1440 secs) even though I'm navigating pages and refreshing. Any ideas?

eelixduppy

12:33 pm on Feb 14, 2007 (gmt 0)



Seems odd. Are you sure you have placed
session_start
in the correct place?

Try a little test script on the server to see if it truly is due to settings and not the script itself.

ahmedtheking

12:55 pm on Feb 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep, it's at the top of all my pages. I've even got a little:

if (empty($_SESSION)) { session_start(); }

Or could that be its undoing?

eelixduppy

12:57 pm on Feb 14, 2007 (gmt 0)




if (empty($_SESSION)) { session_start(); }

Well, I believe this won't work as you might expect, because you aren't initiated the session before you check to see if the $_SESSION global exists. Try taking it out of the conditional to see what happens:


#if (empty($_SESSION)) {
session_start(); #just having this on the top
#}

[edit]
nvm...what you have should work :)...i guess it's worth a try to do the above. Definitely try the small example with another script.
[/edit]

[edit2]
I've just tried a small test to see a couple things. The behavior that you are getting is strange from what you are telling me. Everything you have should work as expected.
[/edit2]

ahmedtheking

1:12 pm on Feb 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've done what you said, taken the empty() check out, I hope it'll work.

ahmedtheking

3:09 pm on Feb 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Still happens!

omoutop

3:17 pm on Feb 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The same thing happens to me quite often.

Sometimes i got around it by addind the following line right below the session_start()

header("Cache-control: private");

Other times i just incerase the session timeout by using
session_cache_limiter();
session_cache_expire();
session_save_path();
ini_set('session.gc_maxlifetime',18000);

Hope those will help you.

PS: haven't figure the why session is timing out.... i am just happy i get around it

ahmedtheking

3:22 pm on Feb 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well I did what you did pretty much but changed the limit to 0; therefore when the browser's closed, it's gone!

omoutop

3:30 pm on Feb 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



sorry i cant provide more assistance.... is it too laet to change it to cookies? :)

barns101

9:16 pm on Feb 14, 2007 (gmt 0)

10+ Year Member



If you're on a shared server and your session data is stored in the default temp directory, your sessions can be timed out prematurely if another user has set their session length and garbage collection to a short value.

You can get around this problem by storing your session data in a temporary directory within your web space.

ahmedtheking

9:20 pm on Feb 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dedicated server me!