Wednesday, 23 May 2012
 Home arrow Blog arrow PHP: Delete or expire a browser cookie
   
Main Menu
Home
News
Blog
Links
Search
FAQs
Spider
Articles
@intrenet
Free Softwares
Break for fun
Friends VIdeos
Techno videos
Contact Us
Disclaimer
Guest Book
Speed test
V.E.C. Calculator
IPv4 Subnet Calc
IPv6 Subnet Calc
Byte Converter
Converter
GMT/UTC Time
Bandwidth Calc
Allinone Calc
IANA Port Numbers
Country Call Codes
Pk Postal Codes
Surf Anonumously
Visitors Counter
mod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_counter
mod_vvisit_counterToday204
mod_vvisit_counterYesterday260
mod_vvisit_counterThis week464
mod_vvisit_counterThis month5013
mod_vvisit_counterAll125689
 
 
 
 


PHP: Delete or expire a browser cookie PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Amanatullah khalil   
Sunday, 24 May 2009

PHP: Delete or expire a browser cookie

 

Cookies may be created with an expiration time. It may become necessary to expire a cookie before the expiration time such as when a user logs out of a cookie-based authentication web application. This recipe describes expiring a cookie.


Expiring a cookie uses the same command as creating a cookie. The cookie value is left blank and the expiration time needs to be in the past. To expire the cookie ‘user’ use:

setcookie('user','',1);

The second parameter is the cookie value and is set to blank with the double quotes. The third parameter is the expiration time. A value of zero here indicates that the cookie is to remain valid until the browser is closed. A positive value indicates the time at which the cookie is to expire. Many sources indicate using something like

setcookie('user','',time()-3600)

which sets the expiration time 3600 seconds (1 hour) in the past. The trick is that this references the time on the server while the cookie expiration is dependent on the time of the host running the browser. If there is a mismatch of time between the two hosts, it is possible that it a cookie may not expire. However, using a time of ‘1′ indicates an expiration time of 1 second after midnight, January 1st, 1970 which is the earliest possible expiration time.

courtesy http://www.tech-recipes.com/rx/1501/php_delete_or_expire_a_browser_cookie/

 
< Prev   Next >
 
 
 
csatpk Newsflash
Statistics
OS: Linux h
PHP: 5.2.17
MySQL: 5.1.63-community-log
Time: 03:57
Caching: Disabled
GZIP: Disabled
Members: 3
News: 368
Web Links: 5
Visitors: 266045
Popular