note 68652 modified in function.session-set-save-handler by felipe
| From: | felipe@php.net | Date: | Sat, 19 Jul 2008 20:32:29 +0000 |
| Subject: | note 68652 modified in function.session-set-save-handler by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-141723@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
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()
?>
--was--
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?
http://php.net/manual/en/function.session-set-save-handler.php