Modify the code so that it provides a web form to collect the cookie values from...

60.1K

Verified Solution

Question

Programming

Modify the code so that it provides a web form to collect thecookie values from the users. In other words, you will add two textboxes where users will enter the cookie name and the cookie value.You will also add a submit button, which lets users to send thecookie values to the server. The page should display the previouscookie values when it is loaded.


    $cookie_name = \"user\";
    $cookie_value = \"John Doe\";
    setcookie($cookie_name, $cookie_value, time() +(86400 * 30), \"/\"); // 86400 = 1 day
?>



if(!isset($_COOKIE[$cookie_name])) {
   echo \"Cookie named '\" . $cookie_name . \"' is notset!\";
} else {
   echo \"Cookie '\" . $cookie_name . \"' isset!
\";
   echo \"Value is: \" . $_COOKIE[$cookie_name];
}
?>

Note: You might have toreload the page to see the value of the cookie.



Answer & Explanation Solved by verified expert
3.7 Ratings (552 Votes)
Code Cookie name Cookie value    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students