note 112684 added to function.session-start

From: Date: Fri, 12 Jul 2013 13:43:28 +0000
Subject: note 112684 added to function.session-start
Groups: php.notes 
Request: Send a blank email to php-notes+get-195584@lists.php.net to get a copy of this message
Had this error: Warning: Unknown: open(/tmp/sess_[[a session id]], O_RDWR) failed: Permission denied (13) Seems that session_start() first creates $_SESSION and then tries to create the session file. Although creating the file fails, the $_SESSION global will be there. Keep in this in mind, because surpressing the write fail with @ will cause your sessions to not work even though you will have a $_SESSION. Further, if you somehow can't solve the write problem (say the folder for session files is on a shared environment and your sessionId's conflict with existing AND you're not willing or able to set a different save_path) you can supress session starts warning (@) and afterwards check the file (session_save_path() . '/sess_' . session_id()) if its readable: @session_start(); $savePath = session_save_path(); $sessionId = session_id(); $sessionFile = $savePath . '/sess_' . $sessionId; if(!is_readable($sessionFile)) { session_regenerate_id(true); session_start(); } Please note that with this write error session_start() returns true (php 5.3) ---- Server IP: 91.199.167.223 Probable Submitter: 92.70.88.182 ---- Manual Page -- http://php.net/manual/en/function.session-start.php Edit -- https://master.php.net/note/edit/112684 Del: integrated -- https://master.php.net/note/delete/112684/integrated Del: useless -- https://master.php.net/note/delete/112684/useless Del: bad code -- https://master.php.net/note/delete/112684/bad+code Del: spam -- https://master.php.net/note/delete/112684/spam Del: non-english -- https://master.php.net/note/delete/112684/non-english Del: in docs -- https://master.php.net/note/delete/112684/in+docs Del: other reasons-- https://master.php.net/note/delete/112684 Reject -- https://master.php.net/note/reject/112684 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#195584) next »