|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-12-02 09:14 UTC] sas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 08:00:02 2025 UTC |
When using the attached code as a custom session handler, everything works fine, but when I call the function getenv(SCRIPT_NAME) inside the write() method, the session will no longer write session data to disk. The logsession() function logs session operations, and will thus show the lack of write() operations when the line: # logsession("Writing $id", getenv(SCRIPT_NAME)); is uncommented. My configure line (from PHPINFO): './configure' '--with-mysql=/usr/local/mysql' '--with-pdflib=/usr/local/pdf' '--with-tiff-lib' '--with-apache=../apache_1.3.12' '--with-ftp' '--with-xml' '--enable-track-vars' Attached Code: <? function logsession($message, $script) { $newMessage = preg_replace("/[\%]/", "", $message); openlog("Diag", LOG_PID, LOG_LOCAL1); syslog(LOG_ERR , "Session -> $newMessage (" . ")"); closelog(); } function open($save_path, $session_name) { global $sess_save_path, $sess_session_name; global $HTTP_GET_VARS; logsession("Opening...", ""); $sess_save_path = $save_path; $sess_session_name = $session_name; return TRUE; } function close() { logsession("Closing...", ""); return TRUE; } function read($id) { global $sess_save_path, $sess_session_name; logsession("Reading $id", ""); $sess_file = "$sess_save_path/sess1_$id"; if ($fp = @fopen($sess_file, "r")) { $sess_data = fread($fp, filesize($sess_file)); return $sess_data; } else { return ""; } } function write($id, $sess_data) { global $sess_save_path, $sess_session_name; # logsession("Writing $id", getenv(SCRIPT_NAME)); $sess_file = "$sess_save_path/sess1_$id"; if ($fp = @fopen($sess_file, "w")) { return fwrite($fp, $sess_data); } else { return FALSE; } } function destroy($id) { global $sess_save_path, $sess_session_name; logsession("Destroying $id", ""); $sess_file = "$sess_save_path/sess1_$id"; return @unlink($sess_file); } function gc($maxlifetime) { return TRUE; } session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); ?>