|
Posted by ZeldorBlat on 09/12/06 15:11
Flaming Corncob wrote:
> Correct me if I'm wrong, but I thought that if you made a change to a
> session, for example (forgive the lame example):
>
> If $_SESSION['tv'] equals "on" and you change it to "off"...
>
> You have to use header() else any changes were lost.
>
> By stupid accident I didn't direct a page through header() after I had
> changed some things in the session and found that even if you closed the
> browser window (not quit the browser - that kills any session) the
> changes I made were ok. This leads me to believe it's possible to make
> any changes to a session without having to redirect with header()? It
> was my understanding that in order for any change to take effect
> header() had to be used.
Session data is stored on the server. A cookie is set on the client
with the "session id" which is used to identify which session on the
server to use. So, any changes you make to the $_SESSION array are
written to the session data on the server. In other words, it doesn't
matter what you do after that. The next request will again present the
session id from the cookie and get the latest and greatest data from
the session.
Navigation:
[Reply to this message]
|