note 112684 deleted from function.session-start by peehaa

From: Date: Mon, 15 Jul 2013 15:15:31 +0000
Subject: note 112684 deleted from function.session-start by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-195622@lists.php.net to get a copy of this message
Note Submitter: jona at dreamit dot nl ---- 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)

« previous php.notes (#195622) next »