Jump to content


Photo

php session help!


  • Please log in to reply
5 replies to this topic

#1 lilywong

lilywong
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 27 July 2006 - 09:23 AM

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

#2 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 27 July 2006 - 09:31 AM

Make sure you had put
session_start();
on the other pages too.

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#3 lilywong

lilywong
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 28 July 2006 - 01:56 AM

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

#4 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 28 July 2006 - 02:01 AM

Pg 1

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

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

is that what you have?
"Syntax error" .. WHERE THE **** IS IT?!

#5 lilywong

lilywong
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 28 July 2006 - 02:15 AM

[quote author=legohead6 link=topic=102045.msg404886#msg404886 date=1154052078]
Pg 1

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

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.


#6 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 28 July 2006 - 02:22 AM

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
"Syntax error" .. WHERE THE **** IS IT?!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users