|
Posted by Flaming Corncob on 09/12/06 18:57
In article <1158073892.551973.254600@i3g2000cwc.googlegroups.com>,
"ZeldorBlat" <zeldorblat@gmail.com> wrote:
> 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.
Well, knowing this helps me a LOT. One of the things I've been trying to
do is use an alert box to send messages to a user if for example the
user enters a wrong password. I've had a work-around without an alert
box that just printed a message through the page they are viewing. I've
only started playing around with alert boxes to see how I might do it
easier and that's how I discovered this about cookies.. by mistake. This
makes things a WHOLE lot easier.
Navigation:
[Reply to this message]
|