Question
· Nov 16, 2019

how to set a expire time for a cookie?

I try to set a cookie with expire time like this:   %response.SetCookie("XXXXX",%session.SessionId, %session.AppTimeout,"","",0,0)  but when i return to the browser it shows that the cookie's("XXXXX") expire time is "session". How can i to set a expire time? Can someone help me? thxsmiley

Discussion (3)0
Log in or sign up to continue

you use %session.AppTimeout which has a default of 900 (sec).

but SetCookie asks for a Time !
method SetCookie(name As %String, value As %String, expires As %String = "", path As %String = "", domain As %String = "", secure As %Boolean = 0, httpOnlyFlag As %Boolean = 0) 

I see from https://stackoverflow.com/questions/13154552/javascript-set-cookie-with-expire-time
what string this might be.

'Mon, 18 Nov 2019 08:50:17 GMT';

My assumption - your 900 was just not recognized and the default (=session) was set