adsense


Showing posts with label VB SCRIPT READING COOKIES. Show all posts
Showing posts with label VB SCRIPT READING COOKIES. Show all posts

Saturday, 7 November 2015

VB SCRIPT READING COOKIES PAGE 27

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button




VB SCRIPT READING COOKIES




Reading Cookies 


Reading a cookie is just as simple as writing one, because 
the value of the document.cookie object is the cookie. 
So, you can use this string whenever you want to access 
the cookie. The document.cookie string will keep a list 
of name=value pairs separated by semicolons where name 
is the name of a cookie and value is its string value. 
You can use strings' split() function to break the string 
into key and values as follows: 
Example 
Following is the example to get the cookies set in the previous section: 
<html> 
<head> 
<script type="text/vbscript"> 
 
Function ReadCookie 
   allcookies = document.cookie 
   msgbox "All Cookies : " + allcookies  
 
   cookiearray  = split(allcookies,";") 
 
   For i=0 to ubound(cookiearray) 
     Name  = Split(cookiearray(i),"=") 
     Msgbox "Key is : " + Name(0) + " and Value is : " + Name(1) 
   Next 
End Function 
 
</script> 
</head> 
<body> 
<form name="myform" action=""> 
<input type="button" value="Get Cookie" onclick="ReadCookie()"/> 
</form> 
</body> 
</html> 
Note : Here, UBound is a method of Array class, which returns 
the length of an array. We will discuss Arrays in a separate
 chapter; until that time, please try to digest it. 
It will produce the following result. Now, press the button 
"Get Cookie" to see the cookies, which you have set in previous section. 
Note: There may be some other cookies already set on your system. 
So, tnhe above code will show you all the cookies set on your system.