Forum Moderators: coopster

Message Too Old, No Replies

Session Weirdness

passes to one page but not another

         

ukgimp

4:45 pm on Mar 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a login page that creates a session with a couple of parameters taken form a database. On one page the variables can be extracted and printed. But on another page they wont print. I cant for the life of me find out why.

Here is how is create them on the login success page

$firstname = mysql_result($sql,$i,"firstname");
$user_id = mysql_result($sql,$i,"user_id");

$_SESSION['user_id'] = "$user_id";
$_SESSION['name'] = "$firstname";
$_SESSION['member'] = true;
header("Location: index.php");

On the index page they can be printed by using:

<?php
$user_id = $_SESSION[user_id];
$name = $_SESSION['name'];
print "Welcome $name , $user_id";

?>

But on the second page that is linked to from this one the same code does not work. Neither variables are present.

What in the name of craziness am I missing.

Cheers

coopster

5:07 pm on Mar 4, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



session_start [php.net]?

lorax

5:10 pm on Mar 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That would be my guess. It should be the very first line in the file that you create the session vars and those that call them.

Bigjohn

5:36 pm on Mar 4, 2004 (gmt 0)

10+ Year Member



Isnt there something you have to do with regards to making sessions work 100% in IE6 too?

John

ergophobe

6:00 pm on Mar 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



For reasons I do not underestand, I have a similar problem on a login page with Firefox/bird and Netscape 7. It works in IE, Opera, Mozilla 1.4 and pretty much everything else.

In the two browsers mentioned, I have to clear the cookies and voila! I get the right session back. I can't figure it out and it perplexes me that Mozilla 1.4 works but not Firefox or Netscape 7.

Tom