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, ∼3096🔥, 0💬
Popular Posts:
How to use the JSON to XML Conversion Tool at freeformatter.com? If you want to try the JSON to XML ...
How to create a "Sign-up or Sign-in" user flow policy in my Azure AD B2C directory? If you want to b...
How to read Atom validation errors at w3.org? If your Atom feed has errors, the Atom validator at w3...
What is the Azure AD v1.0 OpenID Metadata Document? Azure AD v1.0 OpenID Metadata Document is an onl...
How to add request body examples to my Azure API operation to make it more user friendly? If you hav...