PHP4 & sessions
| From: | AJDIN BRANDIC | Date: | Fri, 06 Oct 2000 15:35:43 +0000 |
| Subject: | PHP4 & sessions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-18914@lists.php.net to get a copy of this message | ||
Hi,
I'm trying to understand sessions and I've looked at some tutorials but
still I'm not 100% on it. I want to store session data in the database
rather that use cookies. I now I need to use
session_set_save_handler ("open", "close", "read", "write",
"destroy", "gc");
but how do I specify db name etc. Has anyone got an example script that
actualy work so I can have a look at it.
Also I've tried this script and it returned to me only
open (/tmp, PHPSESSID)
read (db764b17189f06ea34216cb4f6973ed9)
but no write. Does this mean that php.ini need to have
session.save_handler=user?
Thaks,
Ajdin
The script is:
<?php
function open ($save_path, $session_name) {
echo "open ($save_path, $session_name)<br>";
return true;
}
function close () {
echo "close<br>";
return true;
}
function read ($key) {
echo "read ($key)<br>";
return "foo|i:1;";
}
function write ($key, $val) {
echo "write ($key, $val)<br>";
return true;
}
function destroy ($key) {
return true;
}
function gc ($maxlifetime) {
return true;
}
session_set_save_handler ("open", "close", "read", "write",
"destroy",
"gc");
session_start ();
$foo++;
?>