Tools, FAQ, Tutorials:
Mistake on Setting Cookie Path and Domain in PHP
What Is the Common Mistake When Setting Path and Domain on Temporary Cookies in PHP?
✍: FYIcenter.com
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
⇒ Cookies Transported from Servers to Browsers in PHP
⇐ Specifying Domain and Path for a Cookie in PHP
2016-11-03, ∼3183🔥, 0💬
Popular Posts:
Where to find tutorials on Using Azure API Management Publisher Dashboard? Here is a list of tutoria...
How To Read a File in Binary Mode in PHP? If you have a file that stores binary data, like an execut...
How to install "The Windows SDK version 8.1"? I need to build my Visual Studio C++ applications. If ...
Tools, FAQ, Tutorials: JSON Validator JSON-XML Converter XML-JSON Converter JSON FAQ/Tutorials Pytho...
How To Truncate an Array in PHP? If you want to remove a chunk of values from an array, you can use ...