Re: How to print the registered session variables??
| From: | * R&zE: | Date: | Mon, 15 Oct 2001 08:33:44 +0000 |
| Subject: | Re: How to print the registered session variables?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71078@lists.php.net to get a copy of this message | ||
<Original message>
From: Balaji Ankem <balaji.ankem@wipro.com>
Date: Mon, Oct 15, 2001 at 11:14:03AM +0530
Message-ID: <011601c1553c$67b071e0$1702910a@wipro.com>
Subject: [PHP] How to print the registered session variables??
> Hi,
> I have registered two session variables with the names user and pw.
>
> Please tell me how to print those session vars??
>
> Is it needed to call session_register("varname") before printing the
> session variable "varname"??
>
> Thanks and regards
> -Balaji
</Original message>
<Reply>
Hi there :)
It all depends... If you're on a next/different page then where
you've 'started' the session-vars you first have to call
session_start(). After that you can either do:
print ($varname);
or (better):
print ($HTTP_SESSION_VARS["varname"]);
If you're still on the same page as where you 'start' the
session-vars, there are two ways:
First register the variables (otherwise they're not session-vars),
and then you can print them in two ways:
session_register ("varname");
and then:
print ($varname);
or (better):
print ($HTTP_SESSION_VARS["varname"]);
The other way is (when you're still on the same page) to not use
them as session-vars at all (ofcourse depending on what you want to
do with 'm). Then they're still just normal vars ;) :
print ($varname);
If you want to check which session-vars you have available do:
print_r ($HTTP_SESSION_VARS);
or (more info):
var_dump ($HTTP_SESSION_VARS);
Ofcourse you need to call session_start() before this...
</Reply>
--
* R&zE:
-- »»»»»»»»»»»»»»»»»»»»»»»»
-- Renze Munnik
-- DataLink BV
--
-- E: renze@datalink.nl
-- W: +31 23 5326162
-- F: +31 23 5322144
-- M: +31 6 21811143
--
-- Stationsplein 82
-- 2011 LM HAARLEM
-- Netherlands
--
-- http://www.datalink.nl
-- ««««««««««««««««««««««««