Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setcookie does not work (PHP)

Tags:

php

setcookie

What's wrong with this code?

setcookie("password",$wachtwoord,0, "/", ".thedomainname.com");
echo $_COOKIE['password']; //shows nothing

I am attempting to set a cookie and display its value?

like image 874
Jay Avatar asked Apr 07 '26 06:04

Jay


2 Answers

Are you waiting for the next request before you examine $_COOKIE ?

like image 89
Lee Kowalkowski Avatar answered Apr 09 '26 21:04

Lee Kowalkowski


$_COOKIE[] with that new cookie will be available only with next request

like image 34
Larry Cinnabar Avatar answered Apr 09 '26 20:04

Larry Cinnabar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!