Page 1 of 1
passing variables
Posted: Fri Sep 29, 2006 2:35 pm
by jenjenut233
used to be a question here.
Posted: Fri Sep 29, 2006 2:42 pm
by Burrito
sessions are what you're looking for.
have a look
here
Posted: Fri Sep 29, 2006 2:44 pm
by miro_igov
I guess you can use session or cookie
session keeps the variables in $_SESSION array which is accessile on all the pages containing session_start(); function or in all pages even they dont contain session_start() but if s session_autostart is 1 into the php.ini file.
for example you can put session_start(); in the first line of the php script and then use $_SESSION['name'] = "Jen";
then create new page, put session_start(); on top and do echo $_SESSION['name'];
The session identifier is saved in a cookie in the client computer or in the URL depending on the php config settings, so if it's set to save as cookie you should have enabled accepting cookies in browser.
The other option is to keep variables into cookies by using set_cookie("name","Jen");
and print the value by using echo $_COOKIE['name'];
I think session is better.
Posted: Fri Sep 29, 2006 2:50 pm
by jenjenut233
used to be a question here.
Posted: Fri Sep 29, 2006 3:04 pm
by Burrito
you can set session variables on any of the pages you want. The session variables are handled in an array so you can have as many as you'd like.
ex:
Code: Select all
// set your start time when they first arrive
$_SESSION['start'] = time();
// check to make sure that the time has not exceeded their allotted amount.
if($_SESSION['start'] > (time() + 3600)
{
//oops! time's up!
}