Re: session only for who needs it
| From: | Rick Widmer | Date: | Thu, 26 Dec 2002 05:35:44 +0000 |
| Subject: | Re: session only for who needs it | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-92824@lists.php.net to get a copy of this message | ||
At 03:59 AM 12/26/02 +0100, Mattia wrote:
First, this list is for the development _of_ PHP, not development _with_ PHP, so further discussion of this and similar subjects should appear on the php-general list.
I have a site in wich user can register, but everyone can navigate as Guest, even if he/she is nt registered. The problem is that I need session for registered user, but I don't need them for unregistered ones! So I tried to check if they already have an opened session (they are registered), but to check it I have to do a session_start(), and this will OPEN a session if it's not opened! So I'll have an opened session for every guest I have in the site. This is difficult for me because I would like session to last very long, and many empty session waste a lot of space!Try something like: if( isset( $REQUEST[ 'PHPSESSID' ] )) { # User is registered/logged in session_start(); } This is based on looking for the cookie or get value for PHPSESSID, the default session name. If it is set, then either a cookie with the session ID is set, or the session is being passed in the URL. Rick