> 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);

The SID constant var is a good idea! I didn't realize this existed. Taking
what Justin originally suggested, I've now modified the myHeader() function
to only append the SID if it exists (else, it returns the $location var as
it was passed). It also checks to see whether there is a ? in the $location
var. If so, it will append the SID using a &, otherwise it will append the
SID with a ?. 

I haven't tested this yet, but, if anyone has any other suggestions or
recommendations, please post them.

function myHeader($location) {

    if (SID) {
        if (strstr($location, '?')) {
            header("Location: {$location}&".SID);
        } else {
            header("Location: {$location}?".SID);
        }
    } else {
        return $location;
    }
    return;
}


Monty


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to