Closed Bug 290343 Opened 20 years ago Closed 18 years ago

PHP sessions for mydomain.com not realized to be also for www.mydomain.com

Categories

(Core :: Networking: Cookies, defect)

1.0 Branch
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: ferrigno_lou, Assigned: dveditz)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.2
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.2

users try to log in to a url (http://mydomain.com), the login is successful, the
PHP looks for its session, but since www.mydomain.com isn't associated with this
login attempt, authentication fails.  As soon as the user adds the www. to the
beginning of the url in the address bar, it works.  IE on windows and Mac
automagically reconciles the two.  Firefox anywhere doesn't.

Reproducible: Always

Steps to Reproduce:
1.  made sure users leave out the www from urls when logging in
2.
3.

Actual Results:  
login unsuccessful.  Mac IE pops un an error about mismatching security info or
labels (I forget exactly what it said)

Expected Results:  
it should have realized that mydomain.com is www.mydomain.com

no theme or chrome.
PHP sessions are server side. How is authentication tracked in the client?
Cookies? Not http auth, or at least, not at http://mydomain.com -- did you mean
that literally (it exists) or were you using that figuratively as an example? If
the latter please use the reserved "example.com" for placeholders.

Probably going to be hard to figure out without having a legit login. If you're
up to it there are ways to log cookie and http activity on your end that would
help track down the problem.
http://www.mozilla.org/projects/netlib/cookies/cookie-log.html
http://www.mozilla.org/projects/netlib/http/http-debugging.html

It's usually better to have a single site (though good to have both addresses
work). Presumably having http://mydomain.com redirect to http://www.mydomain.com
would also solve your problem.
Thanks for your speedy reply. 

Is mydomain.com a real site?  It seems to be the standard example from the PHP
community, sorry.

OK...so it's cookies used to store the session id for example.com logins.  Turns
out there is a PHP command you can use to set this (it overrides the main php
config file - php.ini) so any session from example.com will work -
dev.example.com, www.example.com, duh.example.com...  Just thought the browser
should be able to figure this one out.  Score one for Micro$oft...ugh.


(In reply to comment #1)
> PHP sessions are server side. How is authentication tracked in the client?
> Cookies? Not http auth, or at least, not at http://mydomain.com -- did you mean
> that literally (it exists) or were you using that figuratively as an example? If
> the latter please use the reserved "example.com" for placeholders.
> 
> Probably going to be hard to figure out without having a legit login. If you're
> up to it there are ways to log cookie and http activity on your end that would
> help track down the problem.
> http://www.mozilla.org/projects/netlib/cookies/cookie-log.html
> http://www.mozilla.org/projects/netlib/http/http-debugging.html
> 
> It's usually better to have a single site (though good to have both addresses
> work). Presumably having http://mydomain.com redirect to http://www.mydomain.com
> would also solve your problem.
(In reply to comment #2)

(Q1) Does your PHP script set "domain=" value(and "path=" if required) in HTTP
header of "Set-Cookie:" for session control(default name is PHPSESSID)
appropriately?
(See "setcookie" in "XLIII. HTTP Functions" section of PHP manual for "domain="
and "path=")
(Q2) Do you set "Cookie accepting policy" in your Firefox's preference
appropriately?

To see what is happening, try next.
(1) Read thru Seesions & Cookies section of PHP manual again. 
    ( http://www.php.net/manual/en/ )
    V. Features
       34. HTTP authentication with PHP
       35. Cookies
       36. Sessions
(2) Check HTTP headers by "Live HTTP headers"
    (See http://livehttpheaders.mozdev.org/index.html for the extention)
(3) Check cookies saved at client using cookie manager.
    (Or by editing "cookies.txt" file in profile directry using text editor.)
(4) Check cookie data sent by client by PHP script.
    - echo '<pre>'.print_r($_COOKIE,TRUE).'</pre>' ;
    - echo '<pre>'.print_r($_SESSION,TRUE).'</pre>' ;
    (See "CXXIX. Variable Handling Functions" of PHP manual)
This is apparently NOT security issue.
Changing to Product=Core,Component=Networking:Cookies. 
Component: Security → Networking: Cookies
Product: Firefox → Core
Version: unspecified → 1.0 Branch
thanks for looking at it.

Mike
This is an automated message, with ID "auto-resolve01".

This bug has had no comments for a long time. Statistically, we have found that
bug reports that have not been confirmed by a second user after three months are
highly unlikely to be the source of a fix to the code.

While your input is very important to us, our resources are limited and so we
are asking for your help in focussing our efforts. If you can still reproduce
this problem in the latest version of the product (see below for how to obtain a
copy) or, for feature requests, if it's not present in the latest version and
you still believe we should implement it, please visit the URL of this bug
(given at the top of this mail) and add a comment to that effect, giving more
reproduction information if you have it.

If it is not a problem any longer, you need take no action. If this bug is not
changed in any way in the next two weeks, it will be automatically resolved.
Thank you for your help in this matter.

The latest beta releases can be obtained from:
Firefox:     http://www.mozilla.org/projects/firefox/
Thunderbird: http://www.mozilla.org/products/thunderbird/releases/1.5beta1.html
Seamonkey:   http://www.mozilla.org/projects/seamonkey/
This bug has been automatically resolved after a period of inactivity (see above
comment). If anyone thinks this is incorrect, they should feel free to reopen it.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → EXPIRED
Status: RESOLVED → UNCONFIRMED
Resolution: EXPIRED → ---
i don't think this is our fault. but you're welcome to explain why it is. traffic logs for msie and mozilla would be appreciated
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago18 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.