#16349 [Sus->Opn]: no way to tell if a session exists without starting it

From: Date: Fri, 28 Oct 2005 21:21:22 +0000
Subject: #16349 [Sus->Opn]: no way to tell if a session exists without starting it
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-87191@lists.php.net to get a copy of this message
ID: 16349 Updated by: david@php.net Reported By: adam at adeptsoftware dot com -Status: Suspended +Status: Open Bug Type: Feature/Change Request Operating System: WinXP PHP Version: 4.1.2 New Comment: powerblade's comment is incorrect, the point of this bug is to determine whether the user has a session without creating a new one if they do not. (session_id always returns a blank string prior to session_start(), regardless of whether an actual session exists). Example: a site wishes to print "Hello <username>" at the top of every page. Username is stored on a session. The site must therefore resume the session to retrieve this username. But it is pointless to *create* a session just for this purpose. A bunch of useless 0-byte sess_* files are wastefully created. In Java, one would do request.getSession(false) - the parameter 'start' set to false causes this function to return null if no session already exists. In PHP, better semantics would be to add a function such as bool session_exists() This still needs to be addressed. Previous Comments: ------------------------------------------------------------------------ [2002-12-03 15:37:01] powerblade at mail dot dk I had the same problem. I wanted to knew if the session was started or not. I found out i should do a session_id(); If it returns "null" then it's not started yet, else it returns the session id. ------------------------------------------------------------------------ [2002-04-14 16:17:06] adam at adeptsoftware dot com Why is this suspended? ------------------------------------------------------------------------ [2002-04-03 12:02:03] adam at adeptsoftware dot com Heh when I think bug I think "flaw", I don't consider basic functionality to be a feature. Knowing if a session has been created or not without having to create one seems pretty basic to me.. ------------------------------------------------------------------------ [2002-04-03 11:57:46] rasmus@php.net I don't know, I am pretty good at having bugs even in stuff I haven't implemented yet. ------------------------------------------------------------------------ [2002-04-03 11:48:19] derick@php.net If it isn't implemented, there can't be a bug in it. Moving this to a feature request. Derick ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/16349 -- Edit this bug report at http://bugs.php.net/?id=16349&edit=1

« previous php.bugs (#87191) next »