Page 1 of 1

retrieving session variables

Posted: Wed Dec 18, 2002 8:01 pm
by feiticeir0
Hi !!

how can i retrieve a session variable ?

after doing this:
<a href="something.php?PHPSESSID=<?php $HTTP_SESSION_VARS["variable"] ?>&something=something">

how can i retrieve the session variable in the other document ?

regards!!

Posted: Wed Dec 18, 2002 8:34 pm
by Rincewind
I'm not sure if I understood your question correctly but....
You can assign variable to $HTTP_SESSION_VARS

Code: Select all

<?php
$HTTP_SESSION_VARS&#1111;'something'] = $something;
?>
Then on any other page using that session this variable is accessible as

$HTTP_SESSION_VARS['something']

Hope that helped.

Rincewind_the_Wizzard

Posted: Wed Dec 18, 2002 10:50 pm
by persaltier
to retrieve the variable on subsequent pages, you'll need to first invoke the session for that page...

you'd do this by starting the session at the top of the page --->

Code: Select all

<?php
session_start();
?>
you'll then refer to the session variable using the $_SESSION superglobal if you're using PHP 4.1 + or $HHTP_SESSION_VAR if you're using an older version.

Code: Select all

<?php
echo $_SESSION[yourvar];  \\ echos your variable in 4.1+
echo $HTTP_SESSION_VAR[yourvar]; \\   <4.1
?>