#17598 [Opn->Bgs]: no way to detect a session without creating a session

From: Date: Sun, 11 Aug 2002 05:45:26 +0000
Subject: #17598 [Opn->Bgs]: no way to detect a session without creating a session
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-16476@lists.php.net to get a copy of this message
ID: 17598 Updated by: kalowsky@php.net Reported By: adam@adeptsoftware.com -Status: Open +Status: Bogus Bug Type: Session related Operating System: WinXP PHP Version: 4.2.1 New Comment: Sure there is, look at the nice patch provided by hans-spath.de! Marking as bogus, as this isn't a bug. Previous Comments: ------------------------------------------------------------------------ [2002-06-05 09:00:03] postings.dynweb@hans-spath.de // just a untested quick-hack // if it doesn't work, I hope you get the idea function session_exists( $name=NULL ) { if( $name === NULL ) $name = ini_get('session.name'); if( ini_get(session.use_cookies) == 1 ) return isset($_COOKIE[$name]); else return isset($_GET[$name]); } ------------------------------------------------------------------------ [2002-06-04 12:40:49] adam@adeptsoftware.com There is no way to detect if a session exists, without creating a session. This can trigger warnings like this in cookie detectors: This page wishes to set the cookie PHPSESSID="bd977b12c9da97f1ba0b07e4fe25a176" A page needs to generate differently based on whether a user is "logged in" (a session exists) or just a "visitor". You shouldn't have to create a session to know if it exists. I suppose you could manually check cookies & the URL etc but shouldn't there be a function for this? ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17598&edit=1

« previous php.bugs (#16476) next »