If you think that this site is helpful, please recommend your friends to visit our site.
How to set cookie and get cookie in php?
The following is the code to read cookies and write cookies with cookie expire:
1. set cookie in php
-------------------------------------------------------------------------------- < ?php setcookie("cookie[acctNo]", "1234", time()+3600); //expire in 1 hour setcookie("cookie[name]", "Tom", time()+3600); setcookie("cookie[age]", "25", time()+3600); ? > -------------------------------------------------------------------------------- 2. get cookie in php -------------------------------------------------------------------------------- < ?php //basic code // $name = $_COOKIE['name']; if (isset($_COOKIE['cookie'])) { foreach ($_COOKIE['cookie'] as $name => $value) { $name = htmlspecialchars($name); $value = htmlspecialchars($value); echo "$name : $value < br / >\n"; } } ? >
No comments:
Post a Comment