Home > Archive > PHP Language > November 2005 > Cookies and Sessions
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Cookies and Sessions
|
|
|
| Hi all
This subject has no doubt come up before, but can't see
anything in this list reading it, so sorry to ask again.
I have a site that uses login and it sets a cookie, I then
use this cookie though the site to keep track of who
they are, it's set to expire 1 hours after they have logged
on.
If they don't log out and come back to the site 10
mins it lets them in again, my client doesn't want this
they want it so once they have left the site then they
must re-log in.
What's the best way to do this? the only thing I can
think of is on each page they go to at 10min to the
expire time of the cookie?
Or how to sessions work?
Brian
| |
| Ben Balbo 2005-11-28, 6:57 pm |
| > they want it so once they have left the site then they
> must re-log in.
Use a session cookie - this way, if *all* browsers are closed, the
session cookie is deleted. To do this, leave the expiry value of
setcookie() blank.
>From php.net: "expire" -- If not set, the cookie will expire at the end
of the session (when the browser closes).
Alternatively, you could get creative with the onunload method of the
body tag so that, unless the user is going to another page in your site,
a request is made to the server that deletes the server-side session info.
|
|
|
|
|