PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
hi ive made a script which sets a cookie on the main page. This main page has links to a different page which also requires to read the cookie that i set. Although, this page which requires the cookie also has another cookie required but it does have a different cookie name. Why does the link also send the cookie for the previously set cookie? thanks
Cookie's are stored client side, so they travel with the user, not the page. When you set the cookie, by default the cookie will work for all pages in the same domain (ie, set a cookie at http://www.foobar.com/testpage1.php and it will be available in all pages on http://www.foobar.com).
Of course, the client needs to have cookies turned on as well, in order for any cookies to work.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
yes... but my cookie is not present on the page and its all on the same domain.. it might be one of my scripts from ages ago that might have deleted all of the cookies except its own. what do u lot think?
<?
$mycookie = $_COOKIE['birdiecookie'];
//another cookie from cookiepage.php is already in this page called birdiecookie2
//probably deletes all of the cookies if any code is present. the birdiecookie2 is from a website database like phpnuke.
echo $mycookie; //nothing happens. no birdiecookie present
?>
Well you said you had a page that deleted all cookies when it was loaded. Go into that page and re-code it so it doesn't delete the two cookies you want to keep.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
hmm so that means the script would need to know what the cookie was called... it doesnt.. weird. i'm going to try a different way just to make things easier. thanks for the help guys
Last edited by birdie on Fri Sep 30, 2005 4:50 pm, edited 1 time in total.