RE: How do I prevent a session from rebuilding itself?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 13 July 2006 00:20, Daevid Vincent wrote:

> > Sequence of events:
> > script starts
> > you rm -rf /tmp/sess_*
> > script writes out data
> > script ends
> > 
> > Exactly WHAT do you think "should" happen in this case?...
> 
> I expect this to work like it USED TO WORK! Bug or not.
> 
> I expect:
> Script starts
> Calls session_start(1234)
> No existing sess_1234 file.
> Creates a new EMPTY sess_1234
> I make $_SESSION['authorized'] = true and PHP writes at that time

Bad assumption there -- the session file isn't necessarily written at this point, only the value in the $_SESSION array.

> I rm /tmp/sess_1234
> Script ends
  ... and the session file is written as part of script shutdown. Boink!

If you really want the session file to be written (and closed) at the point of setting $_SESSION['authorized'], you need a call to session_write_close() [aka session_commit() since PHP 4.3.11].

> Page load again.
> Calls session_start(1234).
> No existing sess_1234 file.
> Creates a new EMPTY sess_1234
> Therefore $_SESSION['authorized'] doesn't exist == false
> 
> But what happens is that PHP actually is writing a new sess_1234
> WITH ALL THE SHIT IT HAD IN RAM
> 
> *sigh*
> 
> Why is this so complicated for anyone to understand?

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux