Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- In response to a Yahoo Answer's Question -->
- <html>
- <head>
- <title>Cookie Test</title>
- <script type="text/javascript" language="Javascript">
- var cookies = new Array();
- function $_COOKIE(cn){
- if(!cookies.loaded){// Cookies need to be sorted and stored.
- var cs = document.cookie.split('; ');
- for( x in cs){
- var t = cs[x].split('=');
- cookies[t[0]] = t[1];
- }
- cookies.loaded = true;
- }
- return cookies[cn];
- }
- function checkCookie(){
- var username = $_COOKIE('username');
- if( username ){
- alert('Username: ' + username);
- }else{
- alert('Username Cookie was not located.\nTo verify:\n username=' + username);
- }
- }
- </script>
- </head>
- <body onload="checkCookie();">
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement