I understand that, but that's what my test was. I set it, then updated it, then went to a new page and it held it's value.
You may not have sessions configured correctly in PHP. Check your php.ini section dealing with sessions to make sure you're not restricting anything.
You might also try using a session name.
An easy way to see if a new session is created is this:
session_start();
echo session_name();
$_SESSION['reg_verify'] = 'TEST';
session_start();
echo session_name();
echo '<script language="javascript" type="text/javascript">';
echo 'alert("'.$_SESSION['reg_verify'].'");';
echo '</script>';
If the session names are different, you need to think of a way of holding a table of values to match up the visitor to the session ID. One way is to use a flat-file and do
hostname session_name
Then it's just a matter of something like this:
<?php
session_start();
include_once('functions.php');
recordSession(session_name());
$_SESSION['reg_verify'] = 'TEST';
?>
<?php
include_once('functions.php');
if(hasSession() == true)
session_name(getSessionName());
session_start();
echo '<script language="javascript" type="text/javascript">
alert("' . $_SESSION['reg_verify'] . '");
</script>';
?>
<?php
$session_info = array();
function recordSession($sessName) {
global $session_info;
if(($key = hasSession(true)) !== false) {
$session_info['host'][$key] = getHost();
$session_info['name'][$key] = $sessName;
}
else {
$session_info['host'][] = getHost();
$session_info['name'][] = $sessName;
}
writeSession($session_info);
}
function hasSession($retKey = false, $sep = ' ') {
global $session_info;
$tmp = file_get_contents('session_table.txt');
$lines = explode($tmp, "\n");
foreach($lines as $line) {
list($session_info['host'][], $session_info['name'][]) = explode($sep, $line);
}
if(($key = array_search(getHost(), $session_info['host'])) !== false) {
if($retKey)
return $key;
else
return true;
}
return false;
}
function getSessionName() {
global $session_info;
if(($key = array_search(getHost(), $session_info['host'])) !== false) {
return $session_info['name'][$key];
}
return false;
}
function getHost() {
return ((!isset($_SERVER['REMOTE_HOST']) || empty($_SERVER['REMOTE_HOST']) ? gethostbyaddr($_SERVRE['REMOTE_ADDR']) || $_SERVER['REMOTE_HOST']);
}
function writeSession($array, $sep = ' ') {
for($i=0; $i<count($array['host']); $i++) {
$sess[] = $array['host'][$i] . $sep . $array['name'][$i];
}
$fp = fopen('session_table.txt', 'w');
foreach($sess as $line) {
fwrite($fp, $line."\n");
}
fclose($fp);
}
?>
Something like that would work. Of course it would be better if it was done with an object, but that should give you an idea.