简体   繁体   中英

Simulate User session with javascript

When a user visits below login screen and provides any user name and password, they should be considered a "logged in" user if they go to any subsequent pages without closing their browser.

<html>
<form action="" method="POST">
<span>Login:</span><input type="text" name="puname" ><br>
<span>Password:</span><input type="text" name="ppasswd"><br>
<input type="submit" value="Register"/>
</form>
</body>
</html>

Can anyone suggest how I can implement this with JavaScript (perhaps using cookies)?

Cookies are the way to go, you can then make the decision if you want them destroyed at browser close, or destroyed after set time(ie 1 day). If your not apposed to jquery, this plugin makes it very simple https://github.com/carhartl/jquery-cookie

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM