php sessions

cfleck

tired
so i'm trying my best to figure out how these sessions work with php. seems pretty straightforward, except this one problem that i can't figure out.

PHP:
<?php 
	// start the session 
	session_start (); 
	
  echo "hi $_SESSION['uid']";
?>

the above prints out absolutely nothing. not a thing. not even "hi".

PHP:
<?php 
	// start the session 
	session_start (); 
?>

hi <?$_SESSION['uid']?>

this one works. why? i'm trying to do some things with these session variables but every time i try to access $_SESSION inside a <?php block it does nothing.
 
I tried your sample code to see if it would work on my machine and I was given a parse error:

parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'

However if I fix the code to read:
PHP:
echo "hi".$_SESSION['uid'];
Then it works, but the only thing output is "hi"
 
that may be it. i'll try it when i get to work tomorrow. i'm new to this php thing. i rarely get error messages. i just get blank web pages. is there a trick to getting error messages?

oh and you won't have a value for the session uid because its a private session variable. you have to do some session mumbo-jumbo to set it.
 
that may be it. i'll try it when i get to work tomorrow. i'm new to this php thing. i rarely get error messages. i just get blank web pages. is there a trick to getting error messages?

oh and you won't have a value for the session uid because its a private session variable. you have to do some session mumbo-jumbo to set it.
 
Back
Top