Connecting Tech Pros Worldwide Forums | Help | Site Map

Help with session vars

Member
 
Join Date: Jan 2007
Posts: 67
#1: Apr 11 '07
I have on one page:
session_start();
session_register ("email");
session_register ("firstname");
session_register ("lastname");
$HTTP_SESSION_VARS ["email"] = $email;
$HTTP_SESSION_VARS ["firstname"] = $firstname;
$HTTP_SESSION_VARS ["lastname"] = $lastname;

when i type:
echo $HTTP_SESSION_VARS ["email"] ;
on this page it displays the users email taken from a form.

I then added a link to another page with a form

when i submit the form it goes to a php script which has
echo $HTTP_SESSION_VARS ["email"] ;
This has no result.

Am i doing something wrong?

ak1dnar's Avatar
Moderator
 
Join Date: Jan 2007
Location: Colombo
Posts: 1,440
#2: Apr 12 '07

re: Help with session vars


Quote:

Originally Posted by Shawn Northrop

I have on one page:
session_start();
session_register ("email");
session_register ("firstname");
session_register ("lastname");
$HTTP_SESSION_VARS ["email"] = $email;
$HTTP_SESSION_VARS ["firstname"] = $firstname;
$HTTP_SESSION_VARS ["lastname"] = $lastname;

when i type:
echo $HTTP_SESSION_VARS ["email"] ;
on this page it displays the users email taken from a form.

I then added a link to another page with a form

when i submit the form it goes to a php script which has
echo $HTTP_SESSION_VARS ["email"] ;
This has no result.

Am i doing something wrong?

Start the session on the second page before you call for the session variable.
[PHP]
<?php
session_start();
echo $HTTP_SESSION_VARS ["email"] ;
?>
[/PHP]
Member
 
Join Date: Jan 2007
Posts: 67
#3: Apr 13 '07

re: Help with session vars


Quote:

Originally Posted by ajaxrand

Start the session on the second page before you call for the session variable.
[PHP]
<?php
session_start();
echo $HTTP_SESSION_VARS ["email"] ;
?>
[/PHP]

Thanks that worked. Do i want to call session_close(); on every page or only when the user logs out?
exoskeleton's Avatar
Member
 
Join Date: Sep 2006
Posts: 104
#4: Apr 14 '07

re: Help with session vars


only when you log out! but what do you want to do...to close the session or destroy it? :)

not just session_destroy() ... you have to clear all the arrays ... many previous topic about clearing the sessions...try to search in this site...i asked about this few months ago...hehe... :)

more power good sir
Reply