Why is my COOKIE unusable like this? Is PHP required to be written in this way?

Source: Internet
Author: User
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) ;}?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.