[thelist] Problems with PHP sessions

Andrew Forsberg andrew at thepander.co.nz
Sat Mar 2 19:46:01 CST 2002


>Sometimes, logging in works on the first try, but then the info is dropped
>when you do to a second page. Other times, it will work fine for 5 minutes
>and quite a few pages.

[...]

>I've coded this on a dev server where I had no problem. What I'm describing
>only started on the production server, so I'm wondering if I should look at
>the way session variables are handled on the server ?  Since this is my
>first time with session variables, I'm not too sure what to look for...
>
>dev server: http://66.39.114.99/pathfinders/
>live server: http://bikerscout.net/pathfinders  (don't tamper with that one,
>please)

Hi Nicole

I can't recreate the problem, but then again, I don't really want to
mess up bikerscout.net to find it by registering several bogus names.

Have you checked that all the links and form action urls are
relative? bikerscout.net is different to www.bikerscout.net as far as
the PHPSESSID cookie is concerned. If someone is moved from
www.bikerscout.net to bikerscout.net (at the moment) a new session
will be created for them.

Perhaps playing around with the session_set_cookie_params() function
will help if you want sessions to be maintained between the two
domains:

http://www.php.net/manual/en/function.session-set-cookie-params.php

I think that setting the domain for sessions to bikerscout.net should
let www.bikerscout.net read the cookie too. Hopefully someone else
more up with cookie behaviour can help out with the best way to do
this.

Second possibility is that if there is a mix of the
session_register() and the $HTTP_SESSION_VARS or $_SESSION arrays in
the program then sessions may be temperamental. It's probably best to
use one method or the other only. (There are a couple of cautions
about this on the main reference page for sessions.)

HTH
Andrew
--



More information about the thelist mailing list