Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Losing sessions in IE

Status
Not open for further replies.

skiflyer

Programmer
Joined
Sep 24, 2002
Messages
2,213
Location
US
Anyone have a problem with this?

I have a simple form, for which if submited with a certain button I use a header("location:...") to take me to another page after putting the $_POST variable into a session variable.

In Firebird this is working great. The $_SESSION array on the new page is there... in IE, it's completely empty.

Anyone seen this before, anyone know a workaround besides using javascript to redirect?

Ugh.

-Rob
 
When you send the header from within the PHP script: what happens to the cookie that identifies the session? Are you sending it also? Maybe IE doesn't pass on the cookie and Firebird does....
 
I know the two handle it entirely differently... if you ever want to goof with it you can tell real quickly...

Open two Firebird windows and play around...
Open two IE windows and play around...

The firebird session will persist between the two windows, the IE one will not. Ah well, I went the javascript route, done it before and it works, I'm just not sure why.

-Rob
 
Mi¢ro$oft has some weird ideas about cookies and the "Location" HTTP header. For example, IIS will not set cookies and send a "Location" header in the same stream.

However, from a LAMP machine, with the following scripts:

test_get_session_location.php:
Code:
<?php
session_start();

$_SESSION['foo'] = $_GET['foo'];

header ('Location: /test_code/test_show_session.php');
?>

test_show_session.php:
Code:
<?php
session_start();

print '<pre>';

print_r ($_SESSION);
?>

When I point IE to [ignore][/ignore]

My browser is directed to [ignore][/ignore]

and the output is

Code:
Array
(
    [foo] => bar
)

So it looks to me like you can successfully use a session and a &quot;Location&quot; header in the same transaction.


Just to ask the dumb question....The domain name of the server which runs the script that sets the session variable and the domain name of the server which runs the script which uses the session variable are the same, right?

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Indeed, they were the same. Unfortunately I can't debug it further at this point (it's working in production and I have a new list of tasks for the end of the week)

If your test works I'm guessing it was a bug in another part of my code that I later cleaned up... that or something particular about my client. I remember running into this issue in the past with IE though so I'm uncertain.

The only difference is that my location header used a fully qualified URL... personally, my theme for this week is getting fed up with IE quirks I develop with Firebird, but ship to a 99% IE environment... did you know you can't start the name of div elements with a number and reference them with javascript in IE? Anyway I'm ranting and way off topic.

-Rob
 
Are you talking about the &quot;name&quot; attribute? If so, IE has it right, not Firebird.

This page ( reads:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens (&quot;-&quot;), underscores (&quot;_&quot;), colons (&quot;:&quot;), and periods (&quot;.&quot;).


Want the best answers? Ask the best questions: TANSTAAFL!!
 
I was actually talking about the ID field, which follows the same rules.

Well, guess I'll give that to them.

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top