Archive

Posts Tagged ‘set cookie’

How to declare a cookie that will destroy after browser is closed

November 29, 2007 1 comment

HI,

I face one problem regarding cookie.Actually, I have to maintain session detail into cookie(rather than session with which i am pretty much used to :)).My problem was to declare a cookie that will destroy after browser is closed.

Cookie can be expired by using simple cmd:

setcookie("testcookie","",time()-3600);

But if User directly closed the browser…then???

If we set the expire time to 0, makes it a browser session cookie, lasting forever,until the browser is closed.

My fix:

setcookie("testcookie","test",0);

Categories: tricks Tags: