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, 1739🔥, 0💬
Popular Posts:
What validation keywords I can use in JSON Schema to specifically validate JSON Array values? The cu...
Where to get the detailed description of the JSON.stringify() Function in JavaScript? Here is the de...
How To Avoid the Undefined Index Error in PHP? If you don't want your PHP page to give out errors as...
What's Wrong with "while ($c=fgetc($f)) {}" in PHP? If you are using "while ($c=fgetc($f)) {}" to lo...
What Is Azure API Management Service? Azure API Management as a turnkey solution for publishing APIs...