-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathultimate-cookie-and-path-vars-pkg.js
More file actions
38 lines (38 loc) · 1.4 KB
/
ultimate-cookie-and-path-vars-pkg.js
File metadata and controls
38 lines (38 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function getVarParse(){
var getVars = new Array();
var locvartemp = ( window.location.href.indexOf( "?" ) + 1 ) ? window.location.href.substr( window.location.href.indexOf( "?" ) + 1 ) : "";
locvartemp = locvartemp.split( "&" );
for( var x = 0; x < locvartemp.length; x++ ) {
var lvTempVar = locvartemp[x].split( "=" );
getVars[ unescape( lvTempVar[0] ) ] = unescape( lvTempVar[1] );
}
return getVars;
}
function setCookie(cname, cvalue, exdays) {
if (exdays != undefined) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires="+d.toUTCString();
document.cookie = encodeURIComponent(cname) + "=" + encodeURIComponent(cvalue) + ";" + expires + ";path=/";
}
else {
document.cookie = encodeURIComponent(cname) + "=" + encodeURIComponent(cvalue) + ";path=/";
}
}
function getCookie(cname) {
var name = encodeURIComponent(cname) + "=";
var ca = document.cookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return decodeURIComponent(c.substring(name.length, c.length));
}
}
return null;
}
function deleteCookie(cname){
document.cookie = encodeURIComponent(cname) +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}