note 111945 added to function.session-status

From: Date: Tue, 16 Apr 2013 07:06:02 +0000
Subject: note 111945 added to function.session-status
Groups: php.notes 
Request: Send a blank email to php-notes+get-194490@lists.php.net to get a copy of this message
The advice of ive_insomnia at live dot com should be taken with great care. First of all, while his use case for session_status is valid, a simpler way to avoid the warning is: <?php if (!isset($_SESSION)) { session_start(); } ?> The example of session_status uses the raw values of constants (2 in this case) created specifically for the purpose of not having to use magic numbers. Better code would be: <?php if (session_status() !== PHP_SESSION_ACTIVE) {session_start();} ?> The same can be done using <? if (session_id() === "") { session_start(); } ?> The use of this function is lies more towards status management: change the behavior of a script when sessions are disabled altogether, for example. ---- Server IP: 83.137.20.135 Probable Submitter: 212.123.157.168 ---- Manual Page -- http://php.net/manual/en/function.session-status.php Edit -- https://master.php.net/note/edit/111945 Del: integrated -- https://master.php.net/note/delete/111945/integrated Del: useless -- https://master.php.net/note/delete/111945/useless Del: bad code -- https://master.php.net/note/delete/111945/bad+code Del: spam -- https://master.php.net/note/delete/111945/spam Del: non-english -- https://master.php.net/note/delete/111945/non-english Del: in docs -- https://master.php.net/note/delete/111945/in+docs Del: other reasons-- https://master.php.net/note/delete/111945 Reject -- https://master.php.net/note/reject/111945 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194490) next »