(CARDING) _ How to set and destroying cookies ?

*Setting or Creating a Cookie*

-A Cookie is created when a browser is told to create one by a web server.
-As long as no Html has yet been transferred, you can call the setcookie function which has the following syntax:
*Setcookie* _( name, value, expire, path, domain, secure, httponly);_
-Following to the above example, once a browser has created a Cookie any request can be made by the browser for the same Domain and cookies that belongs to this domain will be sent back as part of the request .





*Destroying a Cookie*

-To delete a cookie, you must issue it again and set a date in the past.
-It is important for all parameters in your new Setcookie call except the timestamp to be identical to the parameters when the cookie was first issued; otherwise,  the deletion will fail.
-Therefore to delete the Cookie created earlier, you would use the following :
*Setcookie* _("username","Skarter", time() -2592000,"/);_
-As long as the time given is in the past, the Cookie should be deleted.
-However, I have used a time of 2592000 seconds (One Month) in the past in case the client computer's date and time are not correctly set.





Follow us for more...

No comments:

Post a Comment

How to use a solderless breadboard.mp4

  Download now  Enjoy! Follow us for more...