.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, Link to comment https://forums.phpfreaks.com/topic/134634-a-question-about-cookies/ 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 Link to comment https://forums.phpfreaks.com/topic/134634-a-question-about-cookies/#findComment-701012 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 ? Link to comment https://forums.phpfreaks.com/topic/134634-a-question-about-cookies/#findComment-701024 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 Link to comment https://forums.phpfreaks.com/topic/134634-a-question-about-cookies/#findComment-701028 Share on other sites More sharing options...
.Darkman Posted November 28, 2008 Author Share Posted November 28, 2008 Okay, Thanks Link to comment https://forums.phpfreaks.com/topic/134634-a-question-about-cookies/#findComment-701029 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.