[Solved] session_register

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

[Solved] session_register

Post 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
Last edited by ol4pr0 on Mon Aug 30, 2004 8:23 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

session_start() on both pages? $variable set and whatnot?
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post 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..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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().
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

yes it should, and no that doesnt help lol.
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

are those echos on a second page?

remember, you need session_start() on all pages you want session data available.
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

yes those are on other pages..

didnt know about the all pages part i ll try that thanks
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you'll kinda need register_globals being on for that, I believe..
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post 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
Post Reply