SetCookie.htm 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <!--
  2. Licensed Materials - Property of IBM
  3. IBM Cognos Products: CAMAAA
  4. (C) Copyright IBM Corp. 2005, 2012
  5. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
  6. IBM Corp.
  7. -->
  8. <html>
  9. <head>
  10. <meta http-equiv=Content-Type content="text/html; charset=windows-1252">
  11. <title>JavaScript: setting cookies</title>
  12. </head>
  13. <body>
  14. <h3>Set Session Cookie</h3>
  15. <script language="JavaScript">
  16. <!--
  17. letterTable='ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMabcdefghijklmnopqrstuvwxyzabcdefghijklm';
  18. function rot13(str) {
  19. var outStr='';
  20. for (var k=0;k<str.length;k++) {
  21. var ch=str.charAt(k);
  22. var ix=letterTable.indexOf(ch);
  23. outStr+= (ix==-1) ? ch : letterTable.charAt(ix+13) ;
  24. }
  25. return outStr;
  26. }
  27. function SetCookie(cookieName,cookieValue) {
  28. document.cookie = cookieName+"="+escape(cookieValue);
  29. }
  30. //-->
  31. </script>
  32. <form name="setCookie">
  33. <table border=0 cellspacing=3 cellpadding=0>
  34. <tr>
  35. <td>
  36. <p>Cookie Name:</p>
  37. </td>
  38. <td>
  39. <p><INPUT TYPE="TEXT" NAME="t1" VALUE="TRUSTED_SIGNON_USER"></p>
  40. </td>
  41. </tr>
  42. <tr>
  43. <td>
  44. <p>Cookie Value:</p>
  45. </td>
  46. <td>
  47. <p><INPUT TYPE="TEXT" NAME="t2" VALUE="scarter"></p>
  48. </td>
  49. </tr>
  50. <tr>
  51. <td/>
  52. <td>
  53. <p><input type=button value="Set Cookie" name=b1 onclick="SetCookie(this.form.t1.value,this.form.t2.value);parent.location='index.html';">
  54. </td>
  55. </tr>
  56. </table>
  57. </form>
  58. </body>
  59. </html>