Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GetCookie (name) {
- //alert("cookie yang mau diambil = " + name)
- var cookieFound = false;
- var start = 0;
- var end = 0;
- var cookieString = document.cookie;
- var i = 0;
- // SCAN THE COOKIE FOR name
- while (i <= cookieString.length) {
- start = i;
- end = start + name.length;
- if (cookieString.substring(start,end) == name) {
- cookieFound = true;
- break;
- }
- i++;
- }
- // IS name FOUND?
- if (cookieFound) {
- start = end + 1;
- end = document.cookie.indexOf(";",start);
- if (end < start) end = document.cookie.length;
- return document.cookie.substring(start,end);
- }
- return "";
- }
- function SetCookie (name, value) {
- var argv = SetCookie.arguments
- var argc = SetCookie.arguments.length
- var expires = (argc > 2) ? argv[2] : null;
- var path = (argc > 3) ? argv[3] : null;
- var domain = (argc > 4) ? argv[4] : null;
- var secure = (argc > 5) ? argv[5] : false;
- document.cookie = name + "=" + value + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
- }
- function DeleteCookie (name) {
- //alert("will be delete cookie " + name + "with value = " + document.cookie)
- var exp = new Date()
- exp.setTime (exp.getTime() - 1) // This cookie is history
- var cval = GetCookie(name)
- document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement