[PHP] sessions not working when page redirects

2004-08-10 Thread Angelo Zanetti
Hi all, 

Im having a slightly weird problem with my session variables. when on a
certain page call it A, I register a session variable and assign it a
value. I then test if it is registered successfully and has the correct
value on the same page, that works no problem. After that page A
redirects to page B:

header(Location: ../admin/include/B.php);

After this I do the exact same test on page B to test for successful
registration and value and I get that the session variable is not
registered. on page B I do have session_start(); at the top. I even do
2 tests to on the session variable:

if (session_is_registered(myvar))

and 

if (isset($_SESSION[myvar])) 

and they both tell me that the session variable is not registered. what
could be causing the sesssion variable not to be remembered from page to
page. I am using register_globals=on;

any ideas/comments?
Thanks
Angelo

Disclaimer 
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is 
intended for the attention and use only of the addressee. 
Should you have received this e-mail in error, please delete 
and destroy it and any attachments thereto immediately. 
Under no circumstances will the Cape Technikon or the sender 
of this e-mail be liable to any party for any direct, indirect, 
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to 
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] sessions not working when page redirects

2004-08-10 Thread Jason Wong
On Tuesday 10 August 2004 19:50, Angelo Zanetti wrote:

 Im having a slightly weird problem with my session variables. when on a
 certain page call it A, I register a session variable and assign it a
 value. I then test if it is registered successfully and has the correct
 value on the same page, that works no problem. After that page A
 redirects to page B:

 header(Location: ../admin/include/B.php);

Did you close the session before you redirected?

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Think of your family tonight.  Try to crawl home after the computer crashes.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



AW: [PHP] sessions not working when page redirects

2004-08-10 Thread Ron Stiemer
 Hi there,

Try to add the session_id(); into the redirection:

header(Location: ../admin/include/B.php?PHPSESSID= . session_id() );

Works for me though...

Greetings,
-Ron

-Ursprüngliche Nachricht-
Von: Angelo Zanetti [mailto:[EMAIL PROTECTED] 
Gesendet: Dienstag, 10. August 2004 13:51
An: [EMAIL PROTECTED]
Betreff: [PHP] sessions not working when page redirects

Hi all, 

Im having a slightly weird problem with my session variables. when on a
certain page call it A, I register a session variable and assign it a
value. I then test if it is registered successfully and has the correct
value on the same page, that works no problem. After that page A
redirects to page B:

header(Location: ../admin/include/B.php);

After this I do the exact same test on page B to test for successful
registration and value and I get that the session variable is not
registered. on page B I do have session_start(); at the top. I even do
2 tests to on the session variable:

if (session_is_registered(myvar))

and 

if (isset($_SESSION[myvar])) 

and they both tell me that the session variable is not registered. what
could be causing the sesssion variable not to be remembered from page to
page. I am using register_globals=on;

any ideas/comments?
Thanks
Angelo

Disclaimer
This e-mail transmission contains confidential information, which is the
property of the sender.
The information in this e-mail or attachments thereto is intended for the
attention and use only of the addressee. 
Should you have received this e-mail in error, please delete and destroy it
and any attachments thereto immediately. 
Under no circumstances will the Cape Technikon or the sender of this e-mail
be liable to any party for any direct, indirect, special or other
consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] sessions not working when page redirects

2004-08-10 Thread John W. Holmes
From: Angelo Zanetti [EMAIL PROTECTED]
 Im having a slightly weird problem with my session variables. when on a
 certain page call it A, I register a session variable and assign it a
 value. I then test if it is registered successfully and has the correct
 value on the same page, that works no problem. After that page A
 redirects to page B:

 header(Location: ../admin/include/B.php);

This should be a complete URL to begin with:
http://www.yourdomain.com/whatever/admin/include/B.php

 After this I do the exact same test on page B to test for successful
 registration and value and I get that the session variable is not
 registered. on page B I do have session_start(); at the top. I even do
 2 tests to on the session variable:

Using IE?

Try using session_write_close() right before you redirect with the header()
and be sure to put exit() directly after header(). Should look like this
anytime you want to redirect.

session_write_close();
header(...);
exit();

If that doesn't work, then pass the session ID in the URL when you redirect
like someone else mentioned.

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] sessions not working when page redirects

2004-08-10 Thread Ford, Mike [LSS]
On 10 August 2004 13:19, Ron Stiemer wrote:

  Hi there,
 
 Try to add the session_id(); into the redirection:
 
 header(Location: ../admin/include/B.php?PHPSESSID= . session_id() );

No, no, no!  Use the SID constant -- that's what it's for.  It only has a value if you 
need one, so:

  header(Location: ../admin/include/B.php?.SID);

will redirect to include ../admin/include/B.php?PHPSESSID=whatever or 
../admin/include/B.php? as appropriate to the particular circumstances of the current 
invocation of the script.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php