Sessions and IE6

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
sweahe
Forum Commoner
Posts: 52
Joined: Sat May 04, 2002 4:07 am
Location: Växjö, Sweden

Sessions and IE6

Post by sweahe »

What has Microsoft done with the service pack 1 for IE6, after installing SP1 it doesn't accept cookies, my sessions does not work any more!?

What is the solution to this?

This simple little test doesn't work any more!

Code: Select all

<?php
GLOBAL $HTTP_SESSION_VARS;

session_start();
session_register('AVAR');
$HTTP_SESSION_VARS&#1111;'AVAR'] += 1;

echo $HTTP_SESSION_VARS&#1111;'AVAR'];

?>
seg
Forum Commoner
Posts: 38
Joined: Thu Oct 31, 2002 12:08 pm
Location: Northern, VA
Contact:

Re: Sessions and IE6

Post by seg »

sweahe wrote:What has Microsoft done with the service pack 1 for IE6, after installing SP1 it doesn't accept cookies, my sessions does not work any more!?
IE6 has some new methods when dealing with cookies. Check your security settings. Under the new Privacy tab, you will find the new cookie settings.

-seg
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

One thing I noticed immediately that has nothing to do with IE 6: from the manual entry on session_register():
php manual wrote:If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered() and session_unregister().
This means that this need to be changed:

Code: Select all

GLOBAL $HTTP_SESSION_VARS;

session_start(); 
session_register('AVAR'); 
$HTTP_SESSION_VARS&#1111;'AVAR'] += 1; 

echo $HTTP_SESSION_VARS&#1111;'AVAR'];
Firstly session_start() should be at the very top of the page, secondly the rest should be (for PHP 4.1 and above):

Code: Select all

++$_SESSION&#1111;'AVAR'];
echo $_SESSION&#1111;'AVAR'];
or for PHP 4.0.6 or below (assuming that it's within a function otherwise you don't need the global statement):

Code: Select all

global $HTTP_SESSION_VARS;

++$HTTP_SESSION_VARS&#1111;'AVAR'];
echo $HTTP_SESSION_VARS&#1111;'AVAR'];
or

Code: Select all

++$AVAR;
session_register('AVAR');
echo $AVAR;
Mac
sweahe
Forum Commoner
Posts: 52
Joined: Sat May 04, 2002 4:07 am
Location: Växjö, Sweden

Post by sweahe »

There is nothing wrong with the script, it works perfectly in other browsers!
..anyway I did change the script to (no success):

Code: Select all

session_start();
++$_SESSION&#1111;'AVAR'];
echo $_SESSION&#1111;'AVAR'];
(and I have tried the settings too... I set it to accept everything, but it doesn't help!)

I tried to put
session_id('whatever');

in the script just before session_start();

Now the session works in IE too... but I can't have it like that, because then everyone will get the same session... and that's not good! =)
How do I set a session_id myself, that is some kind of random without having it change when hitting F5 (reload) ?
sweahe
Forum Commoner
Posts: 52
Joined: Sat May 04, 2002 4:07 am
Location: Växjö, Sweden

Post by sweahe »

Not much to do about this it seems... the whole subject reads
"Bill was here!"

..again I'm afraid, it's an IE6 bug!
http://bugs.php.net/bug.php?id=15219
Post Reply