
Creating cookies an saving it on client's browser :
<?php setcookie('test',200,time()+(60*60)); ?>As you can see, I have passed three arguments while creating the cookie, the first argument specifies the name of the cookie, second argument specifies the value for the cookie and the third argument specifies the default expiration time of the cookie.
Fetching cookies that are saved on client's browser :
<?php $var1=0; if(isset($_COOKIE['test'])) { $var1=$_COOKIE['test']; } echo $var1; ?>Remember to check if the cookie exist or not before fetching it as cookies can automatically get deleted once the it's expiration time is over.
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.