Hey there! any question in your mind? Ask It Now!.

Popular Categories





can we delete last cookies after click on login button in php?

+6 votes
236 views
asked in Programming by CaptSaltyJack (1,140 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.

1 Answer

+2 votes
answered by amit_pammu Expert (5,030 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.

commented by mannu (990 points)
nice @amit , Could we use this code in cake php also or in WordPress cose also???
commented by anonymous
@mannu: Sure. Setcookie() is a builtin function in PHP, so if you are using PHP 4+ it should work.

Related Questions

+3 votes
3 answers 2,427 views
+2 votes
1 answer 136 views
+6 votes
2 answers 1,521 views
0 votes
1 answer 104 views
+2 votes
1 answer 99 views
asked in Programming by krish Expert (6,310 points)
+6 votes
3 answers 6,828 views
+1 vote
1 answer 180 views
+5 votes
1 answer 1,167 views
+1 vote
2 answers 156 views
+1 vote
2 answers 75 views

Not a Member yet?

Ask to Folks Login

My Account
1077 Folks are online
68 members and 1009 guest online
Your feedback is highly appreciated