How To Send a Cookie to the Browser

Q

How To Send a Cookie to the Browser? - PHP Script Tips - Understanding and Managing Cookies

✍: FYIcenter.com

A

If you want to sent a cookie to the browser when it comes to request your PHP page, you can use the setcookie( ) function. Note that you should call setcookie() function before any output statements. The following script shows you how to set cookies:

<?php
  setcookie("LoginName","FYICenter");
  setcookie("PreferredColor","Blue");
  print("2 cookies were delivered.\n");
?>

2007-04-25, 4806👍, 0💬