+6 votes
343 views
in Programming by (1.1k points)
I want to delete all cookies when a user click on log in button , like on submit want to delete cookie i am using php.

2 Answers

0 votes
by Expert (5.1k points)
reshown by
are you using Core php or Cake php..!!.. in Cake php you have to use the Auth Component
by (1.1k points)
Hello amit i am using core php.
+2 votes
by Expert (5.1k points)

Deleting cookie

It is good to delete a cookie manually from your site. All you do is set the same cookie but with no value and with an expiry date in the past. This forces the browser to delete the cookie from the users system.

 Delete lastVisit cookie from the users system:

<?php 
setcookie ("lastVisit", "", time()-60000); 
?> 

As shown, the value is empty and the expiry date is the current time() minus 60000 seconds, Any negative number will work but due to variations in computer times, it is not recommended to use -1 but instead something higher like a day or two.

by (990 points)
nice @amit , Could we use this code in cake php also or in WordPress cose also???

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated