Jump to content

Archived

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

lilywong

php session help!

Recommended Posts

i am using the old session syntax to create the session, it works fine in index.php, but while i click a hyperlink to page2, the session is gone, where when i echo nothing comes out, usually what kind of problem is it ? thanks

Share this post


Link to post
Share on other sites
Make sure you had put
[code]session_start();[/code]
on the other pages too.

Share this post


Link to post
Share on other sites
i did this, but no print out comes out.

//register session
$user = $this_user;
echo $user;

the echo print out Object id #2

when i do this
//register session
$user = $this_user;
echo $user->domainName;

the echo can print out the domainName, for eg, homeHosting

Share this post


Link to post
Share on other sites
Pg 1

[code]SESSION_START();
$_SESSION['user']="$variable";
[/code]

pg 2
[code]SESSION_START();
$user=$_SESSION['user'];
echo "$user";
[/code]

is that what you have?

Share this post


Link to post
Share on other sites
[quote author=legohead6 link=topic=102045.msg404886#msg404886 date=1154052078]
Pg 1

[code]SESSION_START();
$_SESSION['user']="$variable";
[/code]

the $variable i have is not a defined variable, it is an object, and point to a class file to get the data. in pg1, if i echo echo $user->UserName, it just work fine. when i click to pg2, and echo the same thing, nothing comes out!

if i simply define $_SESSION['user']="test";, and i echo $_SESSION['user'] in pg2, it just works fine.

Share this post


Link to post
Share on other sites
while i just put $variable there so you could replace it i wasnt going to make a whole form...just getting the main idea basicly

Share this post


Link to post
Share on other sites

×

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.