Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-17-2004, 12:53 PM   PM User | #1
Exodious
Regular Coder

 
Join Date: Jul 2002
Posts: 165
Thanks: 0
Thanked 0 Times in 0 Posts
Exodious is an unknown quantity at this point
losing session object when using header("Location:

Hiya,

I've added the header("Location: http://wheretoforward"); to my security class whereas before I was using javascript to forward, and now my serialized session object is null, anyone know why? or will I be forced to use javascript instead?

Saving the object
Code:
# save this object on the session
				$_SESSION["securityObj"] = serialize($this);
								
				#$this->makeJavaScriptStr();
				header("Location: http://".$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) ."/cm/");
Restoring the object on another page
Code:
$sObj = unserialize($_SESSION["securityObj"]);
					
					print "<br>type of securityObj: " . gettype($_SESSION["securityObj"]);
					print "<br>Test variable, getUserLoginName(): " . $sObj->getUserLoginName();
If I don't use the header("location: etc...") and use javascript window.location.href = "some place"; then the object is restored without problems and I can access all its members and properties, yet using the header method to forward users results in the object being Null.

Any ideas welcome
Exodious is offline   Reply With Quote
Old 01-17-2004, 03:18 PM   PM User | #2
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,220
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
Changing pages within a site won't have an effect on the session since it is a browser session for that site. Have you verified that the value is set before the header is given? And is the URL you are redirecting to still within the site, ie not a another different domain or a subdomain? Also you might want to add this to the top of the pages

PHP Code:
error_reporting(E_ALL); 
This will show any errors that may be happening and are not being displayed.
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!

Last edited by Spookster; 01-17-2004 at 03:22 PM..
Spookster is offline   Reply With Quote
Old 01-17-2004, 04:56 PM   PM User | #3
Exodious
Regular Coder

 
Join Date: Jul 2002
Posts: 165
Thanks: 0
Thanked 0 Times in 0 Posts
Exodious is an unknown quantity at this point
Yes, the variable is defo set, if I remove the header line, the forwarding is then controlled by javascript and that works ok

All on the same site etc... perhaps... hmmm, the javascript forwards with window.location.href= 'cm/ '; and the header builds the entire string http://localhost/testarea/cm/, that loses the session, I've just added the SID to end of the path using header, and it works ok.

Thx
Exodious is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:07 PM.


Advertisement
Log in to turn off these ads.