Link to home
Start Free TrialLog in
Avatar of tdsoft
tdsoft

asked on

PHP Sessions and Netscape not working

I'm having the worst time trying to get PHP Sessions to work in Netscape. The variables are just not being carried over to subsequent pages.

My goal is to use sessions once a user has logged in to a site. The following simple test code works fine in IE 5.5, but neither NS 4.7 nor 6. If I can get this to work, the rest is no problem.

---top of page (test1.php)----
<?
session_start();
$SID=session_id();
$ipaddr=$REMOTE_ADDR;
session_register("SID");
session_register("ipaddr");
?>
<html>
<head>
     <title>Sessions Test</title>
</head>
<body>
<a href="test2.php">click here (test2.php)</a>
</body>
</html>
---bottom of page (test1.php)----

---top of page (test2.php)----
<?
session_start();
?>
<html>
<head></head>
<body>
<p>SID = <? echo $SID; ?></p>
<p>ipaddr = <? echo $ipaddr; ?></p>
</body>
</html>
---bottom of page (test2.php)----

So what in the heck am I missing (other than some pulled hair)? Thanks in advance for all your help.
Avatar of a.marsh
a.marsh

Take a look in your php.ini file and tell us the settings for each of the following:

track_vars

register_globals

Was PHP compiled with "--enable-trans-sid"?

:o)

Ant
If "--enable-trans-sid" was not used then change your code from:

<a href="test2.php">click here (test2.php)</a>

to:

<a href="test2.php<?=SID?>">click here (test2.php)</a>


Ant
Avatar of tdsoft

ASKER

Hi there,

track_vars is ON

I'm running on a system where I do not have root access, so can not take a direct look at the php.ini file. However, when running phpinfo() in a page, I do not even see a reference to register_globals.

The session id needs to be transparent, so including it in the URL is not an option. Is there any reason that it would work under IE but not NS?
Sessions work in a number of ways - one is cookies and another is by passing an ID with the URL.

Is Netscape set to accept cookies?

Ant
Avatar of tdsoft

ASKER

Yep, sure is. And I've tried this on multiple computers, using different ISPs too. Bizarre, huh?
Instead of:

<? echo $ipaddr; ?>

try using:

<? echo $HTTP_SESSION_VAR["ipaddr"]; ?>


Ant
Avatar of tdsoft

ASKER

Sorry to say, but still no go.

In looking through the phpinfo() display, I noticed towards the bottom a section labeled 'PHP Variables' which currently contains 2 entries:
PHP_SELF = /alaquote/test1.php
HTTP_COOKIE_VARS["PHPSESSID"] = 54bf660517c9c5c87e01cf1b4648f630

Does that help at all?
Avatar of tdsoft

ASKER

Forgot to mention, but <? echo $HTTP_SESSION_VAR["ipaddr"]; ?> didn't even work in IE where my other variables are still working fine.
Sorry, try:

<? echo $HTTP_SESSION_VARS["ipaddr"]; ?>

Missed off the S.

Ant
Avatar of tdsoft

ASKER

Don't be sorry, I'm just very happy to be getting any help at all. Thank you very much.

But, still no go unfortunately.
It's hard because I have used sessions in PHP and they always work in both browsers fine....

I know you said that attaching the SID is not an option, but could you try it just to see if it works? :o)

Ant
Is your server internal or is it on the Internet?

Ant
Something else to try (I'm trying to compare what I always do to what you have done):

session_start();
session_register("SID");
session_register("ipaddr");
$SID=session_id();
$ipaddr=$REMOTE_ADDR;

I always register the variables first and then set them.

Ant
Avatar of tdsoft

ASKER

I'll try the URL SID in a minute.
The server is on the Internet.
I've gone both ways regarding the order of registering.
Avatar of tdsoft

ASKER

Just tried

<a href="test2.php?SID=<?echo $SID; ?>">click here (test2.php)</a>

and it worked fine in both IE and NS, but that's only to be expected since SID is being declared on test1.php.
As the server is on the Internet, is there any chance of looking at the output of phpinfo() for the server? Perhaps you can give me a link to a script that calls the function?

It may shed some light...

:o)

Ant
In test2.php try using:

session_start($SID);

Ant
Another suggestion - upgrade!!

You are using a beta version of the early version of PHP4 - it is now up to PHP 4.05!!

Ant
Sory tdsoft, but it is getting late here - I'm off to bed at some point in the next half hour - I can continue with this tomorrow. :o)

Ant
ASKER CERTIFIED SOLUTION
Avatar of a.marsh
a.marsh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tdsoft

ASKER

Tell me about it. My ISP is apparently discontinuing upgrades for my line of servers and it looks like I'm going to have to fight to get an upgrade done.

Ordinairily I wouldn't mind, but I'm hosting over 30 domains on this one server and it's going to be a real pain to transfer them to another setup.

I sure appreciate all your help. Enjoy your points.
Avatar of tdsoft

ASKER

Worked hard, so enjoy.

Too bad there really was no answer.

Thanks!
Glad to help - sorry we couldn't get a working solution... but that can be the deal with beta software....

:o\

Thanks for the A grade!

:o)

Ant