Why is my COOKIE unusable like this? Is PHP required to be written in this way? This is a piece of code written in the book two days ago. I wrote comments myself. php page login, unable to get the cookie, but I am in login. echo $ _ POST [& quot; username & quot;] can be used at the beginning of the php page to obtain the value passed from the form, I don't know. it's my cookiemanager. Why is my COOKIE so unusable? Is PHP required to be written in this way?
This is a piece of code written in the book two days ago. I wrote comments myself. php page login, unable to get the cookie, but I am in login. echo $ _ POST ["username"] can be used at the beginning of the php page to obtain the value passed from the form. I don't know if my cookiemanager class is wrong, or what went wrong?
Newbie, I am not quite familiar with the usage of user-defined functions. I will ask you to write the main code as a separate page in PHP and then load it for use? The problem may be a bit small, but this is an important step to be familiar with PHP ··
PHP code
$ Value) {setcookie ($ key, $ value) ;}} public function Set_Cookie ($ key, $ value) {// Set setcookie ($ key, $ value );} public function Get_Array_Cookie () {return $ _ COOKIE;} public function up_Cookie ($ key, $ value) {setcookie ($ key, "", $ time );}} global $ cm; if (! Isset ($ cm) {$ cm = new CookieManager (); // determines whether the $ cm variable exists. if it does not exist, it is instantiated.}?>
PHP code
Get_CookieV ("username") {echo <
Username:
Password:
EOT;} else {print_r ($ cm-> Get_Array_Cookie (); echo'
Exit ';} ob_flush ();?>
------ Solution --------------------
PHP code
$ Value) {setcookie ($ key, $ value) ;}} public function Set_Cookie ($ key, $ value) {// Set setcookie ($ key, $ value );} public function Get_Array_Cookie () {return $ _ COOKIE;} public function up_Cookie ($ key, $ value) {setcookie ($ key, "", $ time) ;}?>