session_set_cookie_params on localhost

This is a discussion on session_set_cookie_params on localhost within the PHP Language forums, part of the PHP Programming Forums category; I want to test locally and can't get past my cookie protection, is this right? It doesn't seem ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-24-2006
elyob
 
Posts: n/a
Default session_set_cookie_params on localhost

I want to test locally and can't get past my cookie protection, is this
right? It doesn't seem to work ...

if ($_SERVER['REMOTE_ADDR']=="127.0.0.1") {
session_set_cookie_params(7200, '/', '.localhost');
} else {
session_set_cookie_params(7200, '/', '.domain.com');
}

Thanks


Reply With Quote
  #2 (permalink)  
Old 05-24-2006
Gordon Burditt
 
Posts: n/a
Default Re: session_set_cookie_params on localhost

>I want to test locally and can't get past my cookie protection, is this
>right? It doesn't seem to work ...
>
>if ($_SERVER['REMOTE_ADDR']=="127.0.0.1") {
> session_set_cookie_params(7200, '/', '.localhost');
>} else {
> session_set_cookie_params(7200, '/', '.domain.com');
>}


Some versions of IE insist (for some security levels) that you have
a P3P privacy policy defined on your server for cookies to work.
Google "p3p privacy policy" and you might want to choose a Microsoft
site that discusses this.

Gordon L. Burditt
Reply With Quote
  #3 (permalink)  
Old 05-24-2006
elyob
 
Posts: n/a
Default Re: session_set_cookie_params on localhost


"Gordon Burditt" <gordonb.qmfj2@burditt.org> wrote in message
news:1277b3734l8qr5e@corp.supernews.com...
> >I want to test locally and can't get past my cookie protection, is this
>>right? It doesn't seem to work ...
>>
>>if ($_SERVER['REMOTE_ADDR']=="127.0.0.1") {
>> session_set_cookie_params(7200, '/', '.localhost');
>>} else {
>> session_set_cookie_params(7200, '/', '.domain.com');
>>}

>
> Some versions of IE insist (for some security levels) that you have
> a P3P privacy policy defined on your server for cookies to work.
> Google "p3p privacy policy" and you might want to choose a Microsoft
> site that discusses this.


Thanks Gordon, will look at this as it's something that I haven't really
considered. However, I am currently developing the area where the cookies
are being used. My issue is that I am unable to test locally as a cookie
isn't being set (I'm using firefox), however it works fine on the remote
server (i.e. .domain.com). I wasted a couple of hours yesterday mucking
about, beacuse I thought there was a problem with the MySQL server .. and it
was the cookie that was at fault.

Will my hack above allow me to test locally (no, is my current answer to
that), or is there another way of testing on localhost I haven't considered?

Thanks


Reply With Quote
  #4 (permalink)  
Old 05-24-2006
Rik
 
Posts: n/a
Default Re: session_set_cookie_params on localhost

elyob wrote:
> I want to test locally and can't get past my cookie protection, is
> this right? It doesn't seem to work ...
>
> if ($_SERVER['REMOTE_ADDR']=="127.0.0.1") {
> session_set_cookie_params(7200, '/', '.localhost');
> } else {
> session_set_cookie_params(7200, '/', '.domain.com');
> }


From php.net:
-------------------------------------------------------
jordi at jcanals dot net
15-Nov-2004 02:39
Something that has taken me some time to debug: session_set_cookie_params()
does not work when the domain param is just a one level domain, like it was
a TLD.

I have a site in an intranet and our internal domain is .local, so trying to
set the cookie session to the .local domain does not work:

session_set_cookie_params(0, '/', '.local'); // Does not work

In all test I've done, setting the domain only works for SLDs and above:

session_set_cookie_params(0 , '/', '.sld.local'); Does work

This is nothing to do with PHP but the http protocol, witch does not permit
setting cookies for TLDs for obvious security reasons.
-------------------------------------------------------

What if you just use session_set_cookie_params(7200, '/');
Or does this break the rest of the script/gets caught in your
cookie-protection?

Grtz,
--
Rik Wasmus


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:32 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0