.Darkman Posted November 28, 2008 Share Posted November 28, 2008 Hello, I've got a question about cookies... Are the cookies accessible only from the site that places it ? For eg, if i use this code on abc.com : setcookie("darkman", "some message", 3600); And, have this on xyz.com : echo $_COOKIE['darkman']; Will it display "some message" on xyz.com ? Thanks, Quote Link to comment Share on other sites More sharing options...
rhodesa Posted November 28, 2008 Share Posted November 28, 2008 for security reasons and to prevent name collisions, cookies are only available to the domain that creates it and it's subdomains edit: so no Quote Link to comment Share on other sites More sharing options...
.Darkman Posted November 28, 2008 Author Share Posted November 28, 2008 Okay... Thank you... But, i created a cookie from http://localhost/dir/index.php And accessed it from http://localhost/index.php and was unable to do it... Why ? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted November 28, 2008 Share Posted November 28, 2008 how did you create it? if you don't supply a PATH (argument #4), it will default to the current directory. your setcookie should look like: setcookie('cookie_name','foobar',0,'/'); p.s. - the 0 means the cookie will expire at the end of the session. you may want to alter that to your needs Quote Link to comment Share on other sites More sharing options...
.Darkman Posted November 28, 2008 Author Share Posted November 28, 2008 Okay, Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.