Re: Sessions and Logins
| From: | Greg Donald | Date: | Fri, 03 Sep 2004 21:35:11 +0000 |
| Subject: | Re: Sessions and Logins | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-195785@lists.php.net to get a copy of this message | ||
On Fri, 2004-09-03 at 15:27, Dennis Gearon wrote:
> I am designing my own 'usr' class that takes care of logins. I need
> to know the following to finish it.
> -------------------------------------------------------------------
> A/ Does anybody use sessions for users who are not logged into the site, and why?
Yes. Because I allow anonymous users _some_ interaction with my site.
> B/ If a user goes from unlogged in, unidentified user to a logged in, identified user, is the
> first session canceled and new session started?
Depends on your definition of "logged in". My users are logged in when
they have $_SESSION['user_id'] set to some integer greater than 0. I
can call session_destroy() to kill the whole session or just unset the
one variable with unset($_SESSION['user_id']). Either way they will be
logged out. I usually follow either method with a header("Location:
index.php") call to some main page in the site.
> C/ (The reverse), if a user goes from logged in, identified user to a unlogged in, unidentified
> user, is the first session canceled and new session started?
Only if you call session_destroy().
> D/ How is it possible, using PHP4+ sessions, to cancel a session a page is opened with, and
> starting a new session?
session_destroy();
--
Greg Donald