I have sessions stored to a database fine; but it won't pass to another page. What could be wrong here?
Start page session code:
require "include/db_control.php";
require "include/html_templates.php";
require "include/form_controls.php";
require "include/SQLutilities.php";
HTMLhead("Welcome To SMCP Review", "include/defaultStyle.css", FALSE);
OpenMySQL();
function mysql_table_exists($table, $link)
{
$exists = mysql_query("SELECT 1 FROM `$table` LIMIT 0", $link);
if ($exists) return true;
return false;
}
if(!mysql_table_exists("sessions",$DB))
{
$query = 'CREATE TABLE sessions
(
SessionID char(255) not null,
LastUpdated datetime not null,
DataValue text,
PRIMARY KEY ( SessionID ),
INDEX ( LastUpdated )
)';
mysql_query($query);
}
function sessao_open($aSavaPath, $aSessionName)
{
global $aTime;
sessao_gc( $aTime );
return True;
}
function sessao_close()
{
return True;
}
function sessao_read( $aKey )
{
$query = "SELECT DataValue FROM sessions WHERE SessionID='$aKey'";
$busca = mysql_query($query);
if(mysql_num_rows($busca) == 1)
{
$r = mysql_fetch_array($busca);
return $r['DataValue'];
} ELSE {
$query = "INSERT INTO sessions (SessionID, LastUpdated, DataValue)
VALUES ('$aKey', NOW(), '')";
mysql_query($query);
return "";
}
}
function sessao_write( $aKey, $aVal )
{
$aVal = addslashes( $aVal );
$query = "UPDATE sessions SET DataValue = '$aVal', LastUpdated = NOW() WHERE SessionID = '$aKey'";
mysql_query($query);
return True;
}
function sessao_destroy( $aKey )
{
$query = "DELETE FROM sessions WHERE SessionID = '$aKey'";
mysql_query($query);
return True;
}
function sessao_gc( $aMaxLifeTime )
{
$query = "DELETE FROM sessions WHERE UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(LastUpdated) > $aMaxLifeTime";
mysql_query($query);
return True;
}
session_set_save_handler("sessao_open", "sessao_close", "sessao_read", "sessao_write", "sessao_destroy", "sessao_gc");
session_start();
header("Cache-control: private");
// Get the user's input from the form
$username = $_POST['username'];
// Register session key with the value
$_SESSION['username'] = $username;
?>
Debug code on another page always shows up "Ok, the session is no longer registered! "
ession_start();
header("Cache-control: private"); //IE 6 Fix
if (isset($_SESSION['username'])) {
echo "The session is still registered.<br /><br />";
} else {
echo "Ok, the session is no longer registered! <br />";
}
Current PHP.INI file session settings:
[Session]
session.save_handler = files
session.save_path = C:\services\php\sessiondata ; argument passed to save_handler
session.use_cookies = 1
; session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.serialize_handler = php
session.gc_probability = 100
session.gc_dividend = 100
session.gc_maxlifetime = 1440
session.bug_compat_42 = 1
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
;session.entropy_length = 16
;session.entropy_file = /dev/urandom
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
Database results thus far:
"6c7fb12079d593365896f4c7647f8b13";"2003-10-29 10:13:31";"username|N;"
"fb0a38489a96e2cb31dad54b9f8821b3";"2003-10-29 10:14:14";"username|N;"
"8a7915880418958bc13691a79868a3d4";"2003-10-29 10:14:18";"username|s:3:\"eve\";"
"5fb67051d11e9325476434e53bb973a1";"2003-10-29 10:14:24";"username|s:3:\"eve\";"
"d36c29b904e99596a5348d3303002745";"2003-10-29 10:17:11";"username|s:3:\"eve\";"