[1151] | 1 | /* Script contendo funcoes de manipulacao de cookies. |
---|
| 2 | // baseado em script de Bill Dortch, hIdaho Design <bdortch@hidaho.com> e |
---|
| 3 | // adaptado por Jorge Kinoshita. |
---|
| 4 | */ |
---|
| 5 | function getCookieVal (offset) { |
---|
| 6 | var endstr = document.cookie.indexOf (";", offset); |
---|
| 7 | if (endstr == -1) |
---|
| 8 | endstr = document.cookie.length; |
---|
| 9 | return unescape(document.cookie.substring(offset, endstr)); |
---|
| 10 | } |
---|
| 11 | |
---|
| 12 | function FixCookieDate (date) { |
---|
| 13 | var base = new Date(0); |
---|
| 14 | var skew = base.getTime(); // dawn of (Unix) time - should be 0 |
---|
| 15 | if (skew > 0) // Except on the Mac - ahead of its time |
---|
| 16 | date.setTime (date.getTime() - skew); |
---|
| 17 | } |
---|
| 18 | // |
---|
| 19 | // Function to return the value of the cookie specified by "name". |
---|
| 20 | // name - String object containing the cookie name. |
---|
| 21 | // returns - String object containing the cookie value, or null if |
---|
| 22 | // the cookie does not exist. |
---|
| 23 | |
---|
| 24 | function GetCookie (name) { |
---|
| 25 | var arg = name + "="; |
---|
| 26 | var alen = arg.length; |
---|
| 27 | var clen = document.cookie.length; |
---|
| 28 | var i = 0; |
---|
| 29 | while (i < clen) { |
---|
| 30 | var j = i + alen; |
---|
| 31 | if (document.cookie.substring(i, j) == arg) |
---|
| 32 | return getCookieVal (j); |
---|
| 33 | i = document.cookie.indexOf(" ", i) + 1; |
---|
| 34 | if (i == 0) break; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | return 'true'; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | function SetCookie (name,value,expires,path,domain,secure) { |
---|
| 41 | document.cookie = name + "=" + escape (value) + |
---|
| 42 | ((expires) ? "; expires=" + expdate.toGMTString() : "") + |
---|
| 43 | ((path) ? "; path=" + path : "") + |
---|
| 44 | ((domain) ? "; domain=" + domain : "") + |
---|
| 45 | ((secure) ? "; secure" : ""); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | var expdate = new Date (); |
---|
| 49 | FixCookieDate (expdate); // Correct for Mac date bug - call only once for given Date object! |
---|
| 50 | expdate.setTime (expdate.getTime() + (30 * 24 * 60 * 60 * 1000)); // Valid for 30 days. |
---|