php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8562 Sessions fail with Netscape
Submitted: 2001-01-05 04:31 UTC Modified: 2001-02-23 01:53 UTC
From: pojanen at pp dot htv dot fi Assigned:
Status: Closed Package: Session related
PHP Version: 4.0.4 OS: Linux 2.2.14
Private report: No CVE-ID: None
 [2001-01-05 04:31 UTC] pojanen at pp dot htv dot fi
PHP 4.0.3 was very buggy with sessions. PHP 4.0.4 works a lot better but I think I have discovered a bug again.

I can't find anything wrong in my code... the bug is very weird. It only happens with Netscape. Netscape Navigator 4.08.

When I try to login (with Netscape 4.08) in my webshop using a form generated by the webshop -> sessions doesn't get saved correctly. But when I press Reload -> the problem will be corrected. With Internet Explorer this works fine at the first time.

Here is the incorrect session data:

SESSION|a:2:{s:12:"ShoppingCart";O:12:"shoppingcart":3:{s:8:"products";a:0:{}s:9:"discounts";a:0:{}s:5:"owner";i:0;}s:12:"ClientConfig";O:12:"clientconfig":3:{s:12:"showPictures";b:1;s:14:"productsOnPage";i:10;s:8:"currency";s:3:"FIM";}}

Here is the correct one (after I press reload or first time with IE):

SESSION|a:2:{s:12:"ShoppingCart";O:12:"shoppingcart":3:{s:8:"products";a:0:{}s:9:"discounts";a:0:{}s:5:"owner";s:1:"2";}s:12:"ClientConfig";O:12:"clientconfig":3:{s:12:"showPictures";b:1;s:14:"productsOnPage";s:1:"8";s:8:"currency";s:3:"FIM";}}

They look pretty same but they are not. owner values should be 2 like in the second example and productsOnPage should be 8.. 0 and 10 are defaults (in the first one) but they are modified to 2 and 8. Somehow PHP doesn't save the modified values.. it saves the first values which are made by my class constructor. (I use $SESSION array which contains two classes)

This is very very STRANGE. Browser shouldn't have anything to do with it but it does. I do no browser checkups so it must be in PHP. If cookies are enabled/disabled it does the same thing.

And btw. This works correctly in PHP 4.0. but not in 4.03 & 4.04.

What could be wrong ?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-06 20:24 UTC] sniper@php.net
Please add a complete but short script which can be used to reproduce this
problem. 

Have you tried newer Netscape versions? 4.08 is quite old.

--Jani

 [2001-01-08 03:00 UTC] pojanen at pp dot htv dot fi
I have tried to get around the problem.. 

Now it always registers the session but it looses a lot of data (classes). Sometimes it works ok.. after pressing reload couple of times. So the problem really is like in PHP 4.03, classes won't be stored properly. But now it's Netscape specific.

I'm using one session variable, $SESSION. It's an array. Which contains ShoppingCart and ClientConfig classes.

So I register the session like this...

session_start();
if(!session_is_registered("SESSION")) session_register("SESSION"); 

In my functions I use $SESSION as global..
global $SESSION;
And when I try to access a function..
$SESSION["ShoppingCart"]->getOwner() it says:
Fatal error: Call to a member function on a non-object in...

Sometimes it works. In IE, always.

Ofcourse I have created the classes inside the session.. 
like this:

if(!isset($SESSION)) $SESSION = array();
if(!isset($SESSION["ShoppingCart"])) $SESSION["ShoppingCart"] = new ShoppingCart;
if(!isset($SESSION["ClientConfig"])) $SESSION["ClientConfig"] = new ClientConfig;  

(The first line is not so important)

Constructors of these classes set variable defaults and creates some arrays. One of the arrays inside the ShoppingCart class constructs from ShoppingCartElement class.

Sorry, not so complete code but I hope it helps.

Btw. I have tried with Netscape 6 and it works Ok.
 [2001-01-17 03:36 UTC] pojanen at pp dot htv dot fi
Hours of debugging... debugging... recoding...

Result: I gues the bug is in Netscape 4.08.. not in PHP.

Reason: If I remove images from the login template it will work. It will also work if I set disk cache to 0.
Too bad... I guess there is no way to fix this.
 [2001-01-17 04:05 UTC] pojanen at pp dot htv dot fi
Argghh... I don't know. Forget the cache.. It didn't help. I don't know where the bug is. Only thing which get it working is to remove images..
 [2001-01-17 04:29 UTC] pojanen at pp dot htv dot fi
Now I remember! The bug must be in PHP because this worked with PHP 4.0 FINE!
 [2001-02-22 04:00 UTC] pojanen at pp dot htv dot fi
Yup... did some testing. I tried all PHP version from 4.0.0 to 4.0.4pl1 and the only version which worked correctly was 4.0.0. 

Too bad....  bug or not. I don't know.  
 [2001-02-23 01:53 UTC] pojanen at pp dot htv dot fi
I have figured a way to get around the bug. My shop would have been nicer without the around trick though. Anyway, back to coding =)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 21:01:29 2024 UTC