bug zhu <bugw...@gmail.com> hat am 24. April 2012 um 08:28 geschrieben:

> thank you for your explanation,
> when i write to $_SESSION after session_commit(),$_SESSION is just a
> regular array

Yes. Actually session_commit does not "terminate" the session as mentioned
earlier but is closes it for writing. You cann still read session values.

The benefit of using session_commit is that the server saved associated
session file is no longer locked, so that parallel requests can both access
the values.

The approach ist as follows:
Call session_commit() as early in you code (after session_open) as possible
to avoid locking. So first do all the writing to the $_SESSION array, then
do write close (or commit). After that you can still read all session
relevant information.

If you want to write afterwards to your $_SESSIOn array you simply have to
call session_start to re-open the write context. Afterwards you can commit
it again to remove the lock.

But be careful! session_start and session_commit perform write operations
on your harddisk or whatever storage you use. Many calls to start and
commit will result in losing performance.


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

Reply via email to