Page 1 of 1
Clarify... SESSION Vars
Posted: Tue Oct 15, 2002 4:06 pm
by Zoram
If i was to set a session variable using session_register() when a person logs in would the variable still be there to retrieve later? How?
I'm a little fuzzy on exactly how session variables work.
session
Posted: Tue Oct 15, 2002 4:53 pm
by AVATAr
The session variable, as the name said, es a variable that is born in the session.
So you register the variable when you start the session and register it. But if the user exits the navigator -> the session exits too, and the varibles will disapear.
The session is a contract between your browser session and the server.. when you close de browser you loose the session
hope it helps
Posted: Tue Oct 15, 2002 5:57 pm
by Zoram
So how do you set them on one page and retrieve them from another?
Posted: Tue Oct 15, 2002 6:01 pm
by volka
session example:
Posted: Tue Oct 15, 2002 6:14 pm
by Fari
page.php
Code: Select all
<?php
session_register('login');
session_register('pwd');
session_register('server');
$login=$login_1;
$pwd = $pwd_1;
$server = $server_1;
?>
<HTML>
<HEAD>
<META NAME="KEYWORDS" CONTENT="test6">
<TITLE>Test</TITLE>
</HEAD>
<BODY text="#1c651c" bg
and in the next script (note the use of the variables $server,$login,$pwd registered in the previous script):
Code: Select all
<?php
session_start();
?>
<HTML>
<HEAD>
<META NAME="KEYWORDS" CONTENT="test7">
<TITLE>Test</TITLE>
</HEAD>
<BODY>
<?php
include 'includes.php';
echo"<TABLE BORDER="1" BORDERCOLOR="#003366" CELLSPACING="1" CELLPADDING="4">";
echo"<TR ALIGN="RIGHT">";
echo"<TD WIDTH="150">";
arial_2("Message : ");
echo"</TD>";
if (!($connection = mysql_connect($server,$login,$pwd)))
{
echo "<TD><font face="arial" size="2" color="#1c651c">Could not Connect!</FONT></TD></TR>";
showerror();
}
Posted: Tue Oct 15, 2002 6:31 pm
by Zoram
So what is the difference between $HTTP_SESSION_VARS and session_register() ? which should i use?
Posted: Tue Oct 15, 2002 10:30 pm
by rev
Posted: Wed Oct 16, 2002 2:11 am
by twigletmac