Page 1 of 1

[Solved] session_register

Posted: Mon Aug 30, 2004 5:21 pm
by ol4pr0
i am trying to find out how the session register kinda works

the following i am trying to do.

Code: Select all

session_register("variable");
#than on a other page.. 

<?if (session_is_registered("variable"))
{
echo 'hello';
}?>
Howeve r this doesnt work

Posted: Mon Aug 30, 2004 5:41 pm
by feyd
session_start() on both pages? $variable set and whatnot?

Posted: Mon Aug 30, 2004 5:47 pm
by ol4pr0
session_start only on index. page.

nothing being returned

Code: Select all

$_SESSION["hi"] = "hello there";
echo $_SESSION['hi']; //Nothing.


#other example
$valid_user = $_POST['username'];
session_register("valid_user");
if (session_is_registered("valid_user")) {echo $username;}// again nothing. or echo 'hello'; for that mather..

Posted: Mon Aug 30, 2004 5:51 pm
by feyd

Code: Select all

$valid_user = $_POST['username'];
session_register("valid_user");
if (session_is_registered("valid_user")) {echo $username;}// again nothing.
shouldn't that be echo $valid_user? :roll:

note:
[php_man]session_register[/php_man] wrote:If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered(), and session_unregister().

Posted: Mon Aug 30, 2004 5:54 pm
by ol4pr0
yes it should, and no that doesnt help lol.

Posted: Mon Aug 30, 2004 5:58 pm
by ol4pr0

Code: Select all

$_SESSION['username'] = $_POST['username'];
echo $_SESSION['username']; // returns nothing.. 
$_SESSION['username'] = "username";
echo $_SESSION['username']; // returns nothing..
Am i missing the point here../ ?

And in case u wondered
register_globals = Off

Posted: Mon Aug 30, 2004 6:04 pm
by feyd
are those echos on a second page?

remember, you need session_start() on all pages you want session data available.

Posted: Mon Aug 30, 2004 6:19 pm
by ol4pr0
yes those are on other pages..

didnt know about the all pages part i ll try that thanks

Posted: Mon Aug 30, 2004 8:14 pm
by ol4pr0
oke this is what i have done now.
on differant pages.

Code: Select all

#page 1
session_start();
$valid_user = $_POST['username'];
session_register("valid_user"); 

# page 2
session_start();
if (session_is_registered("valid_user")) {echo $valid_user;}
Nothing being returned

Posted: Mon Aug 30, 2004 8:20 pm
by feyd
you'll kinda need register_globals being on for that, I believe..

Posted: Mon Aug 30, 2004 8:23 pm
by ol4pr0
yea like that i indeed do lol

Code: Select all

$_SESSION['valid_user'] // Did return hehe..
Thanks for all the help. me so stupid not doing the print_r Grr..r