I have a form which sets the user id, how do you set/read/display the session variable on the called page and all other linked pages?.
called page filepath/index.php
<?php
session_start();
header("Cache-control: private");
echo $user_id;
?>
index.php - self posting form, where user enters member id and the submits form, which calls the following.
<?php
session_start();
header("Cache-control: private");
session_unset();
session_destroy();
$username = $_POST['shareid'];
$con = mysql_pconnect ("localhost", "woolnet_user", "","woolnet_exwool") or die("Error: " . mysql_error());
mysql_select_db ("$db");
$result = mysql_query("SELECT username FROM USERS WHERE username = '$username'");
$row = mysql_fetch_array($result);
if ($username = $row["username"]){
session_register('user_id');
$_SESSION['user_id'] = $username;
header("Location: filepath/index.php");
exit;
} else {
header("Location: 401.shtml");
exit;
}
?>
called page filepath/index.php
<?php
session_start();
header("Cache-control: private");
echo $user_id;
?>
index.php - self posting form, where user enters member id and the submits form, which calls the following.
<?php
session_start();
header("Cache-control: private");
session_unset();
session_destroy();
$username = $_POST['shareid'];
$con = mysql_pconnect ("localhost", "woolnet_user", "","woolnet_exwool") or die("Error: " . mysql_error());
mysql_select_db ("$db");
$result = mysql_query("SELECT username FROM USERS WHERE username = '$username'");
$row = mysql_fetch_array($result);
if ($username = $row["username"]){
session_register('user_id');
$_SESSION['user_id'] = $username;
header("Location: filepath/index.php");
exit;
} else {
header("Location: 401.shtml");
exit;
}
?>