Strange PHP Cookie Problem

software development

#1

I’m using sessions in PHP but have a strange problem.

When I first start a session, it tries to put the Session ID in all of my links. If I immediately reload the page, it correctly uses cookies.

I’m not using any non-standard code.

Has anyone seen this? Is this my problem or PHP’s?

Thanks in advance!


#2

PHP can’t put the SID in all your links unless you’ve specified to do with within your code. Ie, PHP will not take your and convert it to

What’s the other factors in play here? phpBB? A pre-made script?

And I’ve never had an occation where PHP failed to set the sessoin cookie. Which browser are you using? I’d suggest to set your cookies to “always ask” to watch the cookie get set so know exactly where it gets set.


#3

I never said it made sense :wink:

I can see it in FireFox and Safari, I’ll try IE 6 too.

See for yourself:
http://schoolvote.org/session_test.php

First load, SID in links, after that, cookie.

Here’s the code:

[code]<?php

session_start();

$_SESSION[‘foo’] = ‘Hello World’;

echo $_SESSION[‘foo’];

?>


Link 1

Link 2

Link 3

Link 4
[/code]Is this a server issue? That’s my only guess.


#4

I don’t get it appending the sid to end of the links.

http://uk.php.net/session

There is actually a variable that appends session id automatically “url_rewriter.tags”.

This is a quote from a user’s comment
However, if you use ini_set(‘url_rewriter.tags’, ‘’); at the top of your script this will stop the SID being written to the URL’s in PHP4.