PageSourceSearch

https://www.stjohnschelsea.org/Common/Custom/Cookies.js

js stjohnschelsea.org collected 2026-10-09 01:28:37 UTC 2,062 bytes, 63 lines download raw bytes

1//Code from http://techpatterns.com/downloads/javascript_cookies.php
2
3function Set_Cookie(name, value, expiry_days, path, domain, secure)
4{
5	// set time, it's in milliseconds
6	var today = new Date();
7	today.setTime( today.getTime() );
8
9	if (expiry_days)
10		expiry_days = expiry_days * 1000 * 60 * 60 * 24;
11	
12	var expires_date = new Date( today.getTime() + (expiry_days) );
13
14	document.cookie = name + "=" +escape(value) +
15		((expiry_days) ? ";expires=" + expires_date.toGMTString() : "") +
16		((path) ? ";path=" + path : "") +
17		((domain) ? ";domain=" + domain : "") +
18		((secure) ? ";secure" : "");
19}
20
21function Get_Cookie(check_name) {
22	// first we'll split this cookie up into name/value pairs
23	// note: document.cookie only returns name=value, not the other components
24	var a_all_cookies = document.cookie.split( ';' );
25	var a_temp_cookie = '';
26	var cookie_name = '';
27	var cookie_value = '';
28	var b_cookie_found = false; // set boolean t/f default f
29
30	for (i = 0; i < a_all_cookies.length; i++){
31		// now we'll split apart each name=value pair
32		a_temp_cookie = a_all_cookies[i].split( '=' );
33
34		// and trim left/right whitespace while we're at it
35		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
36
37		// if the extracted name matches passed check_name
38		if (cookie_name == check_name){
39			b_cookie_found = true;
40			// we need to handle case where cookie has no value but exists (no = sign, that is):
41			if (a_temp_cookie.length > 1)
42				cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
43				
44			// note that in cases where cookie is initialized but no value, null is returned
45			return cookie_value;
46			break;
47		}
48		a_temp_cookie = null;
49		cookie_name = '';
50	}
51	if (!b_cookie_found)
52		return null;
53}
54
55// this deletes the cookie when called
56function Delete_Cookie(name, path, domain) {
57	if (Get_Cookie(name)) 
58		document.cookie = name + "=" +
59			((path) ? ";path=" + path : "") +
60			((domain) ? ";domain=" + domain : "") +
61			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
62}
63

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.