Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sessions HOWTO - lacking understand and know how on my part

Status
Not open for further replies.

mrmtek

Programmer
Joined
Oct 13, 2002
Messages
109
Location
AU
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;
}
?>
 
thank you all I have now inally got all working as expected, you have all been a great help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top