session variable
Posted: Mon Aug 27, 2007 10:18 am
feyd | Please use
i also include a menu page. which has 3 different links. when i select the link, the session variable no longer displays. help please? i dont know how to keep the session across different pages.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
how do you maintain session variables. i set the variable in a login page, then when i select a link away from the page, my session variable dies.
here's some code.
variable gets set here
this is my login check pageCode: Select all
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
$_SESSION['views']="$myusername";
$_SESSION['id'] = "$id";
while ($row = mysql_fetch_assoc($result)) {
$_SESSION['id']="$row[id]";
echo $_SESSION['id'];
}
gets redirected to home page
<? session_start();
if(isset($_SESSION['views']))
{}
else{
header("location:login.php");
}
?>
<?php include ("header.php"); ?>
<?php
//retrieve session data
echo $_SESSION['views']; // echo's the session which is a username
?><br>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]