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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session problem -- Again 1

Status
Not open for further replies.

Theseekers

Technical User
Jul 22, 2004
118
US
Hi Tekers,

I was playing with the session stuff @ the beginning of this project and with the help of some of you (thank you so much) on this forum I got it working for few pages. Today, I pick up where I left off and what do you know. The darn thing won't carry my capture infor over to the next page.

I went back, looked at my previous notes and compared my setting (php.ini) with my notes along with the session threads in this forum and none can help me.

I thought my code has something to do with it so I created a new series of pages (start from fresh and at least get my session going). None of my session can go beyond the first page. Basically, session is created on the first page (I can see the session id with 1kb size and event open it up to make sure that info is in there which is ok). Click on on a link (a href) to go to the second page. It totally ignores my established session and create a new one with 0kb (What going on here). I've been testing this and try to figure out what has gone wrong and I am fried. Can some of you offer me some suggestions of possible point of failure so I can start to look to see if I can get this going again ( TIA)

My configuration (all in the same laptop)
1. PHP 5.0.0 (installed as ISAPI)
2. IIS 5.0
3. IE 6 with sp1
4. Win2k Server

FYI, I am attaching a few pages that i am testing so you can see what I am trying to do:

page 1

<?php
session_start();
$_SESSION['userid'] = "foo";
print "Session id is: " . session_id();
print "<a href=' go to next page </a>";
?>

page 2
<?php
session_start();
print "Welcome" . $_SESSION['userid'] . "<br />";
print "You have got to page 2 with these information stored in the session: " . $_SESSION['userid'] . " and your session is still: "
echo session_id();

print "<a href=' go to next page </a>";

?>
 
does the test browser allow cookies? session ccokies?

Bastien

Cat, the other other white meat
 
Is the session ID cookie being sent? Check your page via telnet to port 80 (see FAQ434-2999) and see exactly what headers are being sent.

Does the session ID cookie reside in your browser?

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Hi Bastien/sleipnir214

Thanks for your response. I took your suggestion and check them out and this is what I had.

1. Yet the test browser allow coockies and session cookies.
2. Sleipnir - not sure by what do you mean "session id cookies reside in your browser" though. Would you mind elaborate it a little so I can understand it.

3. I tested out to see if the session id cookie being sent from the web via telnet session, and this is what I had:

For page 1

POST /MYPATH/TESTSCRIPT/FIRSTPAGE.PHP HTTP/1.1
HOST: LOCALHOST

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Tue, 11 Jan 2005 23:28:29 GMT
Connection: Close
Content-type: text/html
X-Powered-By: PHP/5.0.0
Set-Cookie: PHPSESSID=021f9c128716d84ce218dd2691c0cd0d; path=/
Expires: Thu, 19 nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache

Session id is: 021f9c128716d84ce218dd2691c0cd0d<a href=' goto next page </a>

With this page I saw it creates a session id with the size of 1KB in the path that specified in the php.ini

Now when I submitted the second page with the same command, I received the similar above message with 2 exceptions:

1. It assigned a different session id file for the second page

2. The size is 0KB.

By looking at the message send back from the web I notice that something is out of ordinary (I hope i am wrong) on this.

On the Expires line after the Set-Cookie line, it sets to expire on Thu 19 Nov 1981 08:52:00 GMT. Does this look right to you???.

Anyway, I hope that you can spot something here that can help me out because I am totally blank.

Thanks again gentlemen.

The seekers is seeking info.....
 
It is a stange value. The "Expires" line you are seeing, though, is for the content of the page, not the expiration of the cookie. You should be able to manipulate that setting though your IIS MMC snapin -- perhaps even turn it off in the settings for your site.



Have you cleared all temporary internet files, including your cookie store?

Have you tried this script with another brand of browser? Mozilla Firefox, for example, allows you, from the browser, to view and remove cookies. This can be very useful when trying to debug cookie problems.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Hi Sleipnir214,

I have cleared out all the cookies and files in the temp. internet files

Run the test again , no luck,

Download the Firefox browser and tried it out, still no luck.

I was reading one of the FAQ about how PHP determines to use or generate a new session id and it makes me think that could I be in this situation when all of those procedure failed; thus a new session is created.

Agrggg.... I am so frustrated for such a simple thing.... Maybe a good night of sleep will clear my head for tomorrow.

TIA for your input and help.

 
still no luck" is a bit vague.

After you hit the first page, does Firefox have a record of the session cookie? Select The Tools/Options menu, then select the Privacy settings on the LH side, then Cookies on the RH side. You will see a button marked "View cookies".

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Good Morning Sleipnir214,

Sorry for the crippted result as you can see my frustration kicks in at the time.

Anyhow, I tried it again this morning and this is what I see. I don't know if any of these can give you some idea as to why mine is not working properly.

After I enter the url for the first page, a session cookie is created. I use the view cookie in Firefox to get the info and it shows.

Site: mapdbmg
Cookie name: PHSESSID

Name : PHSESSID
Content : faf0f920fbfd5599èc4ea7bca91d5f2
Host : mapdbmg
path : /
send for: Any type of connection
Expires : at the end of session


While reponse to your ???. I went ahead and click on the link to go to the second page and use the the view cookie to see if there is any differences between these 2 and what do you know I found a difference. It was in the host name. I modified my test code and wola it works in both browser. You have saved my day again Mr. Sleipnir214.

To be little detailing on the solution:

I entered in the url and this is ok. The session is created with the host being mapdbmg. However, in my code I put in the href as to go to the next page. Obviously, this is the problem. The cookie shows the host as localhost and in fact it was my mistake. I always thought that the localhost and the machine name are interchangeable; I was wrong.

Anyway, thanks a million for leading me to the right direction.

The seekers is out......
 
Damn. My intuition was telling me to ask you about domain names, but with the scripts you posted originally, I overruled myself.

Yes, all HTTP cookies are domain-name specific. This is part of their design and specification -- this link points to the original Netscape page (Netscape invented HTTP cookies) which describes how theywork.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top