Is it possible to delete a blog from the "I read these blogs" list?
session var being lost between pages
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > Java Programming > session var being lost between pages 2 October 2001 14:00:53

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

session var being lost between pages

Jean-Christian Imbeault 2 October 2001 14:00:53
 Ok, newbie I am but ... I seem to be losing my session vars when I load up a
different php page.

My set-up:

1- main page starts session and logs user in

if (isset($PHPSESSID))­
session_start($PHPS­ESSID);
else
session_start();

$PHPSESSID = session_id();
$SID = "PHPSESSID=$PHPSESS­ID";

if(!isset($userid))­ {
login_form();
exit;
}
else {
session_register("u­serid", "userpassword");
}

Once the user is logged in I have no problem accessin the vars $userid and
$userpassword.

On the page I even have an <A HREF> link to second php page and the vars are
accessible there also.

However this other page has a form. When the user submits the form, a third
php page is loaded. On this third page the vars no longer have any values.

Why is this? How can I access the vars from this third page?

Thanks!

Jc



___________________­____________________­____________________­______
Get your FREE download of MSN Explorer at http://explorer.msn­.com/intl.asp

Add comment
Chris Lee 1 October 2001 18:38:59 permanent link ]
 echo $PHPSESSID on every page, is it the same on every page ?

I usually recommend that you create the register variables too.

else {
$userid = '';
$userpassword = '';
session_register('u­serid');
session_register('u­serpassword');
}

if $PHPSESSID is set then session_start() will find it and use it, if your
trying to override HTTP_COOKIE_VARS['PHPSESSID'] with
HTTP_GET_VARS['PHPSESSID'] I would also check if it is not thedefault
allready, change the code to relect that then

if (isset($HTTP_GET_VA­RS['PHPSESSID']) AND $PHPSESSID !=
$HTTP_GET_VARS['PHPSESSID'])

all small things, nothing big looks wrong. try it and see.

--

Chris Lee
lee@mediawaveonline­.com


"Jean-Christian Imbeault" <jean_christian@hot­mail.com> wrote in message
news:F111jy3DzB8zIC­irYfZ0000c3ae@hotmai­l.com...> Ok, newbie I am but ... I seem to be losing my session vars when I load up
different php page.>
My set-up:>
1- main page starts session and logs user in>
if (isset($PHPSESSID))­> session_start($PHPS­ESSID);> else> session_start();>
$PHPSESSID = session_id();> $SID = "PHPSESSID=$PHPSESS­ID";>
if(!isset($userid))­ {> login_form();> exit;> }> else {> session_register("u­serid", "userpassword");> }>
Once the user is logged in I have no problem accessin the vars $userid and> $userpassword.>
On the page I even have an <A HREF> link to second php page and the vars
accessible there also.>
However this other page has a form. When the user submits the form, a
third> php page is loaded. On this third page the vars no longer have any values.>
Why is this? How can I access the vars from this third page?>
Thanks!>
___________________­____________________­____________________­______> Get your FREE download of MSN Explorer at http://explorer.msn­.com/intl.asp>


Add comment
Christian Dechery 2 October 2001 05:41:50 permanent link ]
 are you sure you have session_start() on all three pages and you have
enabled 'track_vars'???
cuz if you don't you'll have to manually pass the session id trought the
form...

At 07:50 1/10/2001 +0000, Jean-Christian Imbeault wrote:>Ok, newbie I am but ... I seem to be losing my session vars when I load up >a different php page.>
My set-up:>
1- main page starts session and logs user in>
if (isset($PHPSESSID))­> session_start($PHPS­ESSID);>else> session_start();>
$PHPSESSID = session_id();>$SID = "PHPSESSID=$PHPSESS­ID";>
if(!isset($userid)­) {> login_form();> exit;>}>else {> session_register("u­serid", "userpassword");>}>­
Once the user is logged in I have no problem accessin the vars $userid and >$userpassword.>
On the page I even have an <A HREF> link to second php page and the vars >are accessible there also.>
However this other page has a form. When the user submits the form, a >third php page is loaded. On this third page the vars no longer have any >values.>
Why is this? How can I access the vars from this third page?>
Thanks!>
__________________­____________________­____________________­_______>Get your FREE download of MSN Explorer at http://explorer.msn­.com/intl.asp>
-->PHP General Mailing List (http://www.php.net­/)>To unsubscribe, e-mail: php-general-unsubsc­ribe@lists.php.net>F­or additional commands, e-mail: php-general-help@li­sts.php.net>To contact the list administrators, e-mail: php-list-admin@list­s.php.net


___________________­__________
. Christian Dechery
. . Gaita-L Owner / Web Developer
. . http://www.webstyle­.com.br
. . http://www.tanamesa­.com.br

Add comment
Jean-Christian Imbeault 2 October 2001 06:44:41 permanent link ]
 Can someone explain this to me? I am not very confused after reading this
post ...
are you sure you have session_start() on all three pages and you have >enabled 'track_vars'???

I have done no such thing. The PHP book I have doesn't mention any of this.
It simply says that using session_start() and session_register() will cause
the vars to be kept between pages. Are you sure what you are sayign is true?

If so please help me understand because I never saw any methion of what you
say must be done in any book or on PHP ML etc ...

Thanks!

Jc

___________________­____________________­____________________­______
Get your FREE download of MSN Explorer at http://explorer.msn­.com/intl.asp

Add comment
Papp Gyozo 2 October 2001 14:00:53 permanent link ]
 He meant that session_start() needs to be invoked on each page.
If you miss it on any page, then PHP assumes that this page does not use
sessions.

track_vars is a configuration directive in PHP.ini
(http://www.php.net­/manual/en/configura­tion.php) this is set to true after
PHP4.0.3
I assume that he thought of register_globals: (from PHP manual)

register_globals
Tells whether or not to register the EGPCS (Environment, GET, POST,
Cookie,Server) variables as global variables. You may want to turn this
off if you don't want to clutter your scripts' global scope with user
data. This makes the most sense when coupled with track_vars - in which
case you can access all of the EGPCS variables through the
$HTTP_ENV_VARS,$HTT­P_GET_VARS,$HTTP_POS­T_VARS, $HTTP_COOKIE_VARS,
and $HTTP_SERVER_VARS arrays in the global scope.

and additionally your original problem:

session_register() registers the _global_(!) variable named by it with
the current session.
session_start() needs no argument.

hth,
Papp Gyozo
- pgerzson@freestart.­hu

----- Original Message -----
From: "Jean-Christian Imbeault" <jean_christian@hot­mail.com>
To: <cdechery@easynet.c­om.br>; <php-general@lists.­php.net>
Sent: Tuesday, October 02, 2001 4:44 AM
Subject: Re: [PHP] session var being lost between pages

Can someone explain this to me? I am not very confused after reading this> post ...>
are you sure you have session_start() on all three pages and you have> >enabled 'track_vars'???>
I have done no such thing. The PHP book I have doesn't mention any of
this.> It simply says that using session_start() and session_register() will
cause> the vars to be kept between pages. Are you sure what you are sayign is
true?>
If so please help me understand because I never saw any methion of what
say must be done in any book or on PHP ML etc ...>
Thanks!>
___________________­____________________­____________________­______> Get your FREE download of MSN Explorer at http://explorer.msn­.com/intl.asp>
--> PHP General Mailing List (http://www.php.net­/)> To unsubscribe, e-mail: php-general-unsubsc­ribe@lists.php.net> For additional commands, e-mail: php-general-help@li­sts.php.net> To contact the list administrators, e-mail: php-list-admin@list­s.php.net>




Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > Java Programming > session var being lost between pages 2 October 2001 14:00:53

see also:
FW: Ubuntu: Start and Stop
I have a question?
track alter table history
пройди тесты:
see also:
System error's blueprint
Bluetooth to be Buried?
A CAMERA REVOLUTION!

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.qaix.com.
Сообщения об ошибках оставляем в сообществе bugs.qaix.com.
Предложения и комментарии пишем в сообществе suggest.qaix.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .