Forum Moderators: coopster
I have a PHP site where 20% of visitors do not have cookie support.
Just curious... is this 20% of real visitors? Or does it include all site traffic, robots, crawlers, etc.?100% real users.
As to your main query, does the PHP Manual: Passing the Session ID [uk.php.net] help?Not fully because it does not explain how to offer both depending on whether the user supports cookies or not.
I'm referring specifically to the security risk of a malicious user hijacking another user's Session or having a legitimate user inadvertently send their Session URL via e-mail/IM to a friend
First page of session: Set up session, set cookie and 302 redirect to a checking page (that has the expected cookie value, and the original request in the url)Status_203, is there anyway to do this without the redirect?
Checking page: Record whether the cookie was passed, 302 redirect again back to the original request, with either cookie or URL parameter as relevant.
if (!isset($_COOKIE['PHPSESSID'])) {
//append SID to URL's automatically
ini_set('session.use_trans_sid', 1);
}
session_start();
If this build option and the run-time option session.use_trans_sid are enabled, relative URIs will be changed to contain the session id automatically.
you can use the constant SID which is defined if the session started. If the client did not send an appropriate session cookie, it has the form session_name=session_id. Otherwise, it expands to an empty string. Thus, you can embed it unconditionally into URLs.