I'm having a prob I can't seem to get my head around.

Most of the time, my sessions work fine. Data is passed to the next page and all is well. But every now and then, on exacly the same pages, they don't work. It seems to suffer short-term memory loss.

I can't figure out why the same pages and code would work most of the time and not on others. The problem isn't isolated to a specific browser or OS, so I'm guessing it's not a client-side problem. And as for the code, I figure either it works or it doesn't... is it something to do with server setup?

From phpinfo() --


Session Support 	enabled
Registered save handlers 	files user

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_dividend	100	100
session.gc_maxlifetime	1440	1440
session.gc_probability	1	1
session.name	PHPSESSID	PHPSESSID
session.referer_check	no value	no value
session.save_handler	files	files
session.save_path	/tmp	/tmp
session.serialize_handler	php	php
session.use_cookies	On	On
session.use_only_cookies	Off	Off
session.use_trans_sid	Off	Off

Anyone out there have any ideas?


    Thanks Matt - but before I cough up $20 for the answer - his issue is on a Windows server - mine is on Linux box - do you know if the answer covers both?

      I found that if you are trying to get the values of the variables held in the session variables by saying

      $local_varname = $_SESSION['varname']

      if you have previously set $local_varname to something (or to a blank), it does not seem to read the value of the session variable. Instead you seem to need to read the variable if the session variable is set or, if not, set it to blank or whatever.

        Thanks irb - I'll have a look at that and let you know how it goes.

          Although - the

          session.name	PHPSESSID

          has a new value on each page as well. Would that be the case if it's just how the $_SESSION variables are allocated? Dunno. I'll try it anyway...

            When you wish to call the Session are you using session_start();

              Hi planetsim,

              Yes, I am. As I mentioned, the majority of the time, it all works fine. Probably 99% of the time. But every now and then it just doesn't. That's what's got me perplexed. I wish it would work all of the time, or none of the time!!!:queasy:

                Hmm might be the session expire working. That happens to me every now and then. You can change that by using ini_set(); [man]ini-set[/man] should help yopu go about it.

                  Thanks planetsim - I'll have a look at that.

                  Just had another thought tho - if the user has cookies disabled all the session info gets passed as GET info, doesn't it? And there is a limit to how much data can get passed using GET... Is that a PHP setting, and Apache setting, or an HTTP setting? Anyone know what that limit is?

                  Hmmm...

                  The session.cookie_lifetime is set to 0, which I believe means it stays until the browser window is closed. I'll try changing that to 10 minutes and see what happens.

                    Write a Reply...