RE: [PHP] Cookies and Sessions: What's the Best Recipe?
| From: | Ford, Mike [LSS] | Date: | Tue, 03 Jun 2003 10:43:36 +0000 |
| Subject: | RE: [PHP] Cookies and Sessions: What's the Best Recipe? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-149925@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Justin French [mailto:justin@indent.com.au]
> Sent: 03 June 2003 06:34
> To: Monty; php-general@lists.php.net
> Subject: Re: [PHP] Cookies and Sessions: What's the Best Recipe?
>
>
> Hmmmm,
>
> Theory only here:
>
> If there is a GET value of PHPSESSID (or whatever your
> sessions are named),
> then the user is more than likely taking advantage of
> trans-sid (sid's in
> the URLs), and cookies are not available.
>
> So, we only want to append the sid to URLs in a redirect IF
> the sid is found
> in the URL already. If there is no SID in the URL, then
> perhaps we can
> assume it doesn't need to be this time????
Guys, that's exactly what the SID predefined constant is for -- it's defined
only when a session is active, and it has the value
<sessionname>=<sessionid> (e.g. PHPSESSID=1afd764ecb938274) if and only if
the session id was passed in the URL -- otherwise it contains the empty
string. So you can safely do:
header("Location: {$location}?".SID);
and get the desired result.