PageSourceSearch

https://www.jewishgen.org/JG/scripts/CookieUtils.js

js jewishgen.org collected 2026-09-24 09:02:50 UTC 1,685 bytes, 67 lines download raw bytes

1// CookieUtils.js
2
3// Utility function called by getcookie():
4function getCookieVal(offset)
5{
6  var endstr = document.cookie.indexOf (";", offset);
7  if (endstr == -1)
8    { endstr = document.cookie.length; }
9  return decodeURI(document.cookie.substring(offset, endstr));
10}
11
12// Function to retrieve cookie by name:
13function getcookie(name)
14{
15  var arg = name + "=";
16  var alen = arg.length;
17  var clen = document.cookie.length;
18
19  var i = 0;
20  while (i < clen)
21  {
22    var j = i + alen;
23    if (document.cookie.substring(i,j) == arg)
24    {
25      return getCookieVal(j);
26    }
27    i = document.cookie.indexOf(" ",i) + 1;
28    if (i==0) break;
29  }
30  return "";
31}
32
33function getsubcookie(xcookie, name)
34{
35  var search = name + "="
36  var returnvalue = "";
37
38  // debug
39  // alert ("Cookie is: '" + xcookie + "'");
40
41  if (xcookie.length > 0)
42    {
43      offset = xcookie.indexOf(search)
44      // if subcookie exists
45      if (offset != -1)
46        {
47          offset += search.length
48          // Set index of beginning of value.
49          end = xcookie.indexOf("&", offset);
50          // Set index of end of value
51          if (end == -1) end = xcookie.length;
52
53          returnvalue = decodeURIComponent(xcookie.substring(offset, end));
54        }
55    }
56  return returnvalue;
57}
58
59// Store cookie value, with optional details as needed.
60function setcookie(name, value, expires, path, domain, secure)
61{
62  document.cookie = name + "=" + encodeURIComponent(value) +
63	((expires) ? "; expires=" + expires : "") +
64	((path) ? "; path=" + path : "") +
65	((domain) ? "; domain=" + domain : "") +
66	((secure) ? "; secure=" + secure : "");
67}

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.