A common mistake made by many PHP developers is using an empty string for the expiration time parameter when setting path and domain for temporary cookies. The PHP script below shows an example of this mistake:<?php # Incorrect use of setcookie() setcookie("LoginName","FYICenter", "", "/", ".fyicenter.com"); # Correct use of setcookie() setcookie("PreferredColor","Blue", NULL, "/", ".fyicenter.com");?>If you run this script, you will get an error:PHP Warning: setcookie() expects parameter 3 to be long, string given in \php_working_with_cookies.php on line 3
PHP
Topic: Cookies
What Is the Common Mistake When Setting Path and Domain on Temporary Cookies?
Browse random answers:
How To Send a Cookie to the Browser?
How To Test Cookies on a Web Server?
How To Set a Persistent Cookie?
How To Test Persistent Cookies?
What Are Domain and Path Attributes for Cookies?
How To Specify Domain and Path for a Cookie?
What Is the Common Mistake When Setting Path and Domain on Temporary Cookies?
How Cookies Are Transported from Servers to Browsers?
How To View Cookie Header Lines?
How Cookies Are Transported from Browsers to Servers?
Where Are the Persistent Cookies Stored on Your Computer?
How To Delete Cookie Files on Your Computer?
How Many Cookies Can You Set?
What is a Cookie?
How to Create a Cookie?
What is syntax of setcookie?
How to Retrieve a Cookie Value?
How to Delete a Cookie?
What is the meaning of a Persistent Cookie?
What does $_COOKIE means?