How can i create a cookie by using javascript just for end of the browser session(ie,upto closing of current browser).My script is like follows;
function setCookie(c_name,c_value,c_expiredays) {
var exdate=new Date();
exdate.setDate(exdate.getDate()+c_expiredays);
document.cookie=c_name+ "=" +escape(c_value)+
((c_expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
setCookie('gs_cookie','firstme',1600000);
How much value i need to pass instead of 1600000. Please help....
A cookie is an amount of information that persists between a server-side and a client-side. A web browser stores this information at the time of browsing. A cookie contains the information as a string generally in the form of a name-value pair separated by semi-colons.
An HTTP cookie (web cookie, browser cookie) is a small piece of data that a server sends to a user's web browser. The browser may store the cookie and send it back to the same server with later requests.
There are three main types of cookies: session, persistent and third-party.
The secure attribute is always activated for secured cookies, so it is transmitted with encrypted connections, without any hassles and security issues. The httpOnly flag does not give cookie access to JavaScript or any non-HTTP methods. This is situated in the secure cookie header.
If you dont set any expire time, the cookie will be deleted upon closing of the browser:
setCookie('gs_cookie','firstme');
Setting c_expiredays
to 0
(without quotes) should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With