note 68652 added to function.session-set-save-handler

From: Date: Sat, 05 Aug 2006 04:20:43 +0000
Subject: note 68652 added to function.session-set-save-handler
Groups: php.notes 
Request: Send a blank email to php-notes+get-115562@lists.php.net to get a copy of this message
the behavior, return values, and exact time of calling for these functions is pretty poorly documented here. i thought folks might like to know that: 1) calling session_start() triggers PHP to first call your open function and then call your read function before resuming with the code immediately following your session_start() call. 2) calling session_id('some_value') within your open function WILL NOT SET THE SESSION COOKIE (at least not on my setup - PHP 4.4.1). Assuming you defined some function to validate a session id called my_func(), you might want to do something like this in your open function: [PHP] <?php function _open($save_path, $session_name) { // check for session id $sess_id = session_id(); if (empty($sess_id) || !myfunc($sess_id)) { //session_id is INVALID - generating new $new_id = md5(uniqid("some random seed here")); session_id($new_id); setcookie(session_name(), $new_id, 0, "/", ".mydomain.com"); } return true; } // _open() ?> [/PHP] PS: CAN WE GET SOME REAL DOCUMENTATION FOR WHAT THESE FUNCTIONS ARE, WHAT THEY REQUIRE, WHEN THEY ARE CALLED, AND WHAT EXACTLY THEY ARE SUPPOSED TO DO? ---- Server IP: 64.71.164.2 Probable Submitter: 70.36.216.90 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.session-set-save-handler.php Edit -- https://master.php.net/note/edit/68652 Del: integrated -- https://master.php.net/note/delete/68652/integrated Del: useless -- https://master.php.net/note/delete/68652/useless Del: bad code -- https://master.php.net/note/delete/68652/bad+code Del: spam -- https://master.php.net/note/delete/68652/spam Del: non-english -- https://master.php.net/note/delete/68652/non-english Del: in docs -- https://master.php.net/note/delete/68652/in+docs Del: other reasons-- https://master.php.net/note/delete/68652 Reject -- https://master.php.net/note/reject/68652 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115562) next »