|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-06-04 12:40 UTC] adam at adeptsoftware dot 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? PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 15:00:02 2025 UTC |
// 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]); }