Expire cookie in 5 minutes

Hi All

I need this coookie to expire in 5 minutes.


CURRNENT CODE:

<script language="JavaScript">
<!--

function SetCookie(){
document.cookie = "UserHasCookie=Yes; path=/";
}

//-->
</script>
blnukemAsked:
Who is Participating?
 
TimYatesCommented:
   var now = new Date() ;
    now.setMinutes( now.getMinutes() + 5 ) ;
    document.cookie = "UserHasCookie=Yes; expires=" + now.toGMTString() + "; path=/";

should work...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.