Advertisement
A_GUES

sign up

Jul 29th, 2023
1,512
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.12 KB | None | 0 0
  1. <form id="signupForm">
  2.   <label for="username">Username:</label><br>
  3.   <input type="text" id="username" name="username"><br>
  4.   <label for="password">Password:</label><br>
  5.   <input type="password" id="password" name="password"><br>
  6.   <input type="submit" value="Submit">
  7. </form>
  8.  
  9. <script>
  10. document.getElementById('signupForm').addEventListener('submit', function(event) {
  11.   event.preventDefault();
  12.  
  13.   var username = document.getElementById('username').value;
  14.   var password = document.getElementById('password').value;
  15.  
  16.   // Here you would usually send the user data to your server
  17.   // console.log('User signed up with username: ' + username + ' and password: ' + password);
  18.  
  19.   // Set a cookie to store the username
  20.   document.cookie = "username=" + username + "; expires=Thu, 18 Dec 2023 12:00:00 UTC; path=/";
  21.  
  22.   // Now you can access the cookie like this
  23.   var allCookies = document.cookie;
  24.   console.log("All cookies: " + allCookies);
  25.  
  26.   // If you want to delete the cookie, you can uncomment the following line
  27.   //document.cookie = "username=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
  28. });
  29. </script>
  30.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement