Guest User

Untitled

a guest
Jan 26th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. function setCookie(c_name,value,exdays)
  2. {
  3. var exdate=new Date();
  4. exdate.setDate(exdate.getDate() + exdays);
  5. var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
  6. document.cookie = c_name + "=" + c_value;
  7. }
  8.  
  9. var loginval = slmgusername=swetha.p + slmguserpassword = 12345678;
  10. setCookie("slmgusercredentails", loginval, 100);
  11.  
  12. HttpContext.Request.Cookies["slmgusercredentials"].Values = {slmgusername%253Dswetha.p%2526slmguserpassword%253D12345678}
  13.  
  14. UserName = HttpContext.Request.Cookies["slmgusercredentials"].Values["slmgusername"].
  15.  
  16. function ReadCookie()
  17. {
  18. var allcookies = document.cookie;
  19. alert("All Cookies : " + allcookies );
  20.  
  21. // Get all the cookies pairs in an array
  22. cookiearray = allcookies.split(';');
  23.  
  24. // Now take key value pair out of this array
  25. for(var i=0; i<cookiearray.length; i++){
  26. name = cookiearray[i].split('=')[0];
  27. value = cookiearray[i].split('=')[1];
  28. alert("Key is : " + name + " and Value is : " + value);
  29. }
  30. }
  31.  
  32. function readKeyValuesFromCookie(){
  33. return document.cookie
  34. .split( ';' )
  35. .map( pair => pair.split( '=' ) )
  36. .filter( pair => pair.length == 2 )
  37. .map( pair => [ pair[0].trim(), pair[1].trim() ] )
  38. .filter( pair => pair[0] != 'expires' )
  39. ;
  40. }
Add Comment
Please, Sign In to add comment