I am trying to set up a session setup that saves session data to a mysql database.
I have gone into php.ini and set session.save_handler to user. I call the following include file up using session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); (of course I have labeled each function correctly as they appear in my include file, just too lazy to write it all out here). When I run the page this is on, I get a parse error at the line where function session_open is in the include file (see below) Any idea why? Thanks I am modeling this word for word from a example found at: http://www.onlamp.com/pub/a/php/2001/05/10/sessions.html?page=1 (pages 1 thru 3) my session include file: <? // Session Table $sess_table = "Sessions"; // Retrieve the session maximum lifetime (found in php.ini) $lifetime = get_cfg_var("session.gc_maxlifetime"); //============= // function: mysql_session_open() // purpose: Opens a persistent server connection and selects the // database. //============= mysql_session_open($session_path, $session_name) { // parse error on this line; mysql_pconnect("localhost", "mysql_username", "mysql_password") or die("Can't connect to MySQL server! "); mysql_select_db("sessions_database") or die("Can't select MySQL sessions database"); } // end mysql_session_open() //============= // function: mysql_session_close() // purpose: Doesn't actually do anything since the server connection is // persistent. Keep in mind that although this function // doesn't do anything in my particular implementation, I // still must define it. //============= mysql_session_close() { return 1; } // end mysql_session_close() //============= // function: mysql_session_select() // purpose: Reads the session data from the database //============= mysql_session_select($SID) { GLOBAL $sess_db; GLOBAL $sess_table; $query = "SELECT value FROM $sess_table WHERE SID = '$SID' AND expiration > ". time(); $result = mysql_query($query); } // end mysql_session_select() //============= // function: mysql_session_write() // purpose: This function writes the session data to the database. If that SID // already exists, then the existing data will be updated. //============= mysql_session_write($SID, $value) { GLOBAL $sess_db; GLOBAL $sess_table; GLOBAL $lifetime; $expiration = time() + $lifetime; $query = "INSERT INTO $sess_table VALUES('$SID', '$expiration', '$value')"; $result = mysql_query($query, $sess_db); if (! $result) : $query = "UPDATE $sess_table SET expiration = '$expiration', value = '$value' WHERE SID = '$SID' AND expiration >". time(); $result = mysql_query($query, $sess_db); endif; } // end mysql_session_write() //============= // function: mysql_session_destroy() // purpose: deletes all session information having input SID (only one row) //============= mysql_session_destroy($sessionID) { GLOBAL $sess_table; $query = "DELETE FROM $sess_table WHERE SID = '$sessionID'"; $result = mysql_query($query); } // end mysql_session_destroy() //============= // function: mysql_session_garbage_collect() // purpose: deletes all sessions that have expired. //============= mysql_session_garbage_collect($lifetime) { GLOBAL $sess_table; $query = "DELETE FROM $sess_table WHERE sess_expiration < ".time() - $lifetime; $result = mysql_query($query); return mysql_affected_rows($result); } // end mysql_session_garbage_collect() ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]