wordpress - PHP session cookies to expire when browser closes -
i working in wordpress , have following in functions.php page.
i have array of 3 different styles. cookie doing randomizing.
if (isset($_cookie['style'])){ $style = $_cookie['style']; } else { $style = ($rand[$stylearray]); setcookie('style',$style,time(),cookiepath,cookie_domain,false); }
i want set cookie only expires when browser closes. however, seems on page refresh(f5) cookie expires.
is there way set cookie expires on browser close?
the http://www.w3schools.com/php/func_http_setcookie.asp says
optional. specifies when cookie expires. value: time()+86400*30, set cookie expire in 30 days. if parameter omitted or set 0, cookie expire @ end of session (when browser closes). default 0
so
setcookie('style',$style, 0 , ...);
or
setcookie('style',$style, '', ...);
must work.
Comments
Post a Comment