Solved

PHP Sessions and Netscape not working

Posted on 2001-06-13
24
167 Views
Last Modified: 2008-03-10
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.
0
Comment
Question by:tdsoft
  • 14
  • 10
24 Comments
 
LVL 15

Expert Comment

by:a.marsh
ID: 6187357
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
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6187370
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
0
 

Author Comment

by:tdsoft
ID: 6187416
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?
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6188165
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
0
 

Author Comment

by:tdsoft
ID: 6188182
Yep, sure is. And I've tried this on multiple computers, using different ISPs too. Bizarre, huh?
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6188227
Instead of:

<? echo $ipaddr; ?>

try using:

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


Ant
0
 

Author Comment

by:tdsoft
ID: 6188281
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?
0
 

Author Comment

by:tdsoft
ID: 6188291
Forgot to mention, but <? echo $HTTP_SESSION_VAR["ipaddr"]; ?> didn't even work in IE where my other variables are still working fine.
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6188326
Sorry, try:

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

Missed off the S.

Ant
0
 

Author Comment

by:tdsoft
ID: 6188388
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.
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6188612
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
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6188632
Is your server internal or is it on the Internet?

Ant
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 15

Expert Comment

by:a.marsh
ID: 6188641
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
0
 

Author Comment

by:tdsoft
ID: 6188660
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.
0
 

Author Comment

by:tdsoft
ID: 6188675
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.
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6188687
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
0
 

Author Comment

by:tdsoft
ID: 6188708
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6188724
In test2.php try using:

session_start($SID);

Ant
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6188728
Another suggestion - upgrade!!

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

Ant
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6188768
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
0
 
LVL 15

Accepted Solution

by:
a.marsh earned 150 total points
ID: 6188794
Here are some interesting "bug" pages I found with regards to PHP4.0B2 (you really need to upgrade!!! You should never use a beta version for "live" sites!):

http://www.php.net/bugs.php?id=2735

http://www.php.net/bugs.php?id=2612

http://www.php.net/bugs.php?id=2228

http://www.php.net/bugs.php?id=2126

Ant
0
 

Author Comment

by:tdsoft
ID: 6188816
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.
0
 

Author Comment

by:tdsoft
ID: 6188821
Worked hard, so enjoy.

Too bad there really was no answer.

Thanks!
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6188835
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
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now