note 106773 added to function.session-status

From: Date: Mon, 05 Dec 2011 19:21:31 +0000
Subject: note 106773 added to function.session-status
Groups: php.notes 
Request: Send a blank email to php-notes+get-184917@lists.php.net to get a copy of this message
This is to provide for a sane way of handling the starting of a session without triggering the E_NOTICE complaining about a session having already been started ("Notice: A session had already been started - ignoring session_start()"). Consider: <?php // 1000's of lines of code, which may/may not have started a session session_start(); ?> *If* you've already started a session, then you'll get the infamous E_NOTICE. However, you can't really be sure that a session hasn't already been started before attempting to start one. Thus, the answer is: <?php // 1000's of lines of code, which may/may not have started a session if (session_status() == PHP_SESSION_NONE) { session_start(); } ?> See bug report @ https://bugs.php.net/bug.php?id=52982 for more info. ---- Server IP: 69.147.83.197 Probable Submitter: 74.202.235.42 ---- Manual Page -- http://www.php.net/manual/en/function.session-status.php Edit -- https://master.php.net/note/edit/106773 Del: integrated -- https://master.php.net/note/delete/106773/integrated Del: useless -- https://master.php.net/note/delete/106773/useless Del: bad code -- https://master.php.net/note/delete/106773/bad+code Del: spam -- https://master.php.net/note/delete/106773/spam Del: non-english -- https://master.php.net/note/delete/106773/non-english Del: in docs -- https://master.php.net/note/delete/106773/in+docs Del: other reasons-- https://master.php.net/note/delete/106773 Reject -- https://master.php.net/note/reject/106773 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#184917) next »