HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <script> var name = "Steve"; var uName = ""; var age = "25"; var uAge = ""; //Cookie write document.cookie = "username="+name+";path=/"; document.cookie = "userage="+age+";path=/"; // Cookie read all allcookie=(document.cookie); // Convert string to array cookiearray = allcookie.split(";"); // Run through array cookiearray.forEach(function(element){ if(element.indexOf("username")>-1) uName=element.slice((element.indexOf("username=")+9), element.length); if(element.indexOf("userage")>-1) uAge=element.slice((element.indexOf("userage=")+8), element.length); }); // Print the username document.write(uName+" is "+uAge+" years old."); </script> </body> </html>
OUTPUT
×

Save as Private