PageSourceSearch

https://www.aulaformacion.org/campus/lib/cookies.js

js aulaformacion.org collected 2026-10-04 13:25:14 UTC 2,423 bytes, 84 lines download raw bytes

1/*******************************************************
2COOKIE FUNCTIONALITY
3Based on "Night of the Living Cookie" by Bill Dortch
4(c) 2003, Ryan Parman
5http://www.skyzyx.com
6Distributed according to SkyGPL 2.1, http://www.skyzyx.com/license/
7*******************************************************/
8function cookie(name, value, expires, path, domain, secure)
9{
10	// Passed Values
11	this.name=name;
12	this.value=value;
13	this.expires=expires;
14	this.path=path;
15	this.domain=domain;
16	this.secure=secure;
17
18	// Read cookie
19	this.read=function()
20	{
21		// To allow for faster parsing
22		var ck=document.cookie;
23
24		var arg = this.name + "=";
25		var alen = arg.length;
26		var clen = ck.length;
27		var i = 0;
28
29		while (i < clen)
30		{
31			var j = i + alen;
32			if (ck.substring(i, j) == arg)
33			{
34				var endstr = ck.indexOf (";", j);
35				if (endstr == -1) endstr = ck.length;
36				return unescape(ck.substring(j, endstr));
37			}
38			i = ck.indexOf(" ", i) + 1;
39			if (i == 0) break;
40		}
41		return null;
42	}
43
44	// Set cookie
45	this.set=function()
46	{
47		// Store initial value of "this.expires" for re-initialization.
48		expStore=this.expires;
49
50		// Set time to absolute zero.
51		exp = new Date();
52		base = new Date(0);
53		skew = base.getTime();
54		if (skew > 0)  exp.setTime (exp.getTime() - skew);
55		exp.setTime(exp.getTime() + (this.expires*24*60*60*1000));
56		this.expires=exp;
57
58		document.cookie = this.name + "=" + escape (this.value) +
59				((this.expires) ? "; expires=" + this.expires.toGMTString() : "") +
60				((this.path) ? "; path=" + this.path : "") +
61				((this.domain) ? "; domain=" + this.domain : "") +
62				((this.secure) ? "; secure" : "");
63
64		// Re-initialize
65		this.expires=expStore;
66	}
67
68	// Kill cookie
69	this.kill=function()
70	{
71		document.cookie = this.name + "=" +
72				((this.path) ? "; path=" + this.path : "") +
73				((this.domain) ? "; domain=" + this.domain : "") +
74				"; expires=Thu, 01-Jan-70 00:00:01 GMT";
75	}
76
77	// Change cookie settings.
78	this.changeName=function(chName) { this.kill(); this.name=chName; this.set(); }
79	this.changeVal=function(chVal) { this.kill(); this.value=chVal; this.set(); }
80	this.changeExp=function(chExp) { this.kill(); this.expires=chExp; this.set(); }
81	this.changePath=function(chPath) { this.kill(); this.path=chPath; this.set(); }
82	this.changeDomain=function(chDom) { this.kill(); this.domain=chDom; this.set(); }
83	this.changeSecurity=function(chSec) { this.kill(); this.secure=chSec; this.set(); }
84}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.