Read
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | / ** * Returns the value of a cookie * * @ Example Var res = * getCookie ('variable'); * * / name ) { getCookie function (name) { document. cookie . indexOf ( name + "=" ) ; var start = document. cookies. indexOf (name + "="); start + name . length + 1 ; var len = start + name. length + 1; ! start ) && ( name != document. cookie . substring ( 0 , name . length ) ) ) return ( null ) ; if ((! start) & & (name! = document. cookies. substring (0, name. length))) return (null); start == - 1 ) return ( null ) ; if (start == - 1) return (null); document. cookie . indexOf ( ";" , len ) ; var end = document. cookies. indexOf ("", len); end == - 1 ) end = document. cookie . length ; if (end == - 1) end = document. cookies. length; unescape ( document. cookie . substring ( len , end ) ) ) ; return (unescape (document. cookies. substring (len, end))); } |
Write
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | / ** * Set a cookie * * @ Example * * SetCookie ('variable', 'value', 10); * * / name , value , expiredays , path , domain , secure ) { setCookie function (name, value, expiredays, path, domain, secure) { new Date ( ) ; var expires = new Date (); expires. getDate ( ) + expiredays ) ; expires. setDate (getDate expires. () + expiredays); name + "=" + escape ( value ) + cookieString var = name + "=" + escape (value) + ? ";expires=" + expires. toGMTString ( ) : "" ) + ((Expires)? "Expires =" + expires. ToGMTString (): "") + ? ";path=" + path : "" ) + ((Path)? "Path =" + path: "") + ? ";domain=" + domain : "" ) + ((Domain)? "Domain =" + domain: "") + ? ";secure" : "" ) ; ((Secure)? "Secure": ""); cookieString ; document. cookieString = cookie; } |
Eliminate
1 2 3 4 5 6 7 8 9 10 11 12 13 | / ** * Delete a cookie * * @ Example * DeleteCookie ('variable'); * * / name , path , domain ) { deleteCookie function (name, path, domain) { getCookie ( name ) ) document. cookie = name + "=" + if (getCookie (name)) document. cookie = name + "=" + ? ";path=" + path : "" ) + ((Path)? "Path =" + path: "") + ? ";domain=" + domain : "" ) + ((Domain)? "Domain =" + domain: "") + "Expires = Thu, 01-Jan-70 00:00:01 GMT"; } |











I did not understand one thing: I would like to put a button on my site that has the function to erase all cookies from my site so that the page will reload to update the html files.
How can I do?
@ Paul: You should be more clear ... as you can see from the code brought a cookie is deleted by name. So you should, first of all, know all the cookies you have written. However I did not understand what you mean by "will update the html files" ... maybe you want to get something else with cookies does not have much to do, I mean update ... explain the problem better
OK then I'll try to be clearer. When I update the pages of my site, for example, I edit the index.html and on the FTP host. So far so good. When I go to my site, the home that is the index. Html is not changed. To see it changed many times I reload the page or delete cookies. For this I want to create a button that deletes the cookies issued from my site (of which I know the names) and then reload the page automatically.
I hope I was clear
@ Paul: I think your problem NOT depend on cookies. A cookie, in fact, can do many things but I doubt prevent the refresh of your page in the browser, unless it was specifically created a system of this type. What you should check, however, is:
1) The settings of your web server about the cache
2) The settings of your browser (perhaps using Explorer and then view section that determines how it should behave when the browser reloads the same page)
3) If you entered the index.html nalla your
TAG METAto force a cache cleaningIf you still want to try deleting your cookies by inserting the button that you told me, the procedure is quite simple: associate the button - or link - a Javascript function that deletes cookies to cookie with the function presented in this post, type:
2
3
4
5
6
) ; deleteCookie ("var1");
) ; deleteCookie ("var2");
/ / ...
) ; deleteCookie ("Varna");
}
By 1000, however, ok my site is hosted on altervista. Maybe that's the prob.
Since I'm here, I'd like a link exchange or banner exchange. Or if I may say a "trick" to make a site popular
@ Paul:
Write (well), respond to and do not rush