Jump to content

Session variables - id doesnt want to pass.


markspec87

Recommended Posts

2 of my variables will work but the third just doesnt want to work and im stumped why.

index page code:
[code]
if (isset($_SESSION['username']))
{
    echo "Welcome back " . $_SESSION['username'];
    echo "click <a href='logout.php'>here</a> to logout<BR>";
    echo "click <a href='editprofile.php?id=" .$_SESSION['userid']. "'>here</a> to edit your profile<BR>";
    echo $_SESSION['userid'];

}
else
{
    echo "your not signed up, <a href='signup.php'>signup</a> now or <a href='login.php'>login!</a>";
}[/code]

the 4th echo for userid was just for debugging, but its still not working. The username works fine.

Login code: (relevant)

[code]if(mysql_num_rows($result) == 1)
{
    // retrieve the access level
    $row = mysql_fetch_assoc($result);
   
    // set the session vars:
    $_SESSION['username'] = $_POST['username'];
    $_SESSION['accesslevel'] = $row['accesslevel'];
    $_SESSION['userid'] = $row['id'];
}[/code]

The row definitely exists and has values in the records, yet on the main page the variable is always null.

Any ideas guys?
Link to comment
https://forums.phpfreaks.com/topic/30163-session-variables-id-doesnt-want-to-pass/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.