If I set a username in index.html, and then I jump to the b.html page from this page, how can I use this user name for this page?
Reply content:
If I set a username in index.html, and then I jump to the b.html page from this page, how can I use this user name for this page?
In principle, it is used SESSION
or COOKIE
implemented. But if you are not a dynamic program (based on other dynamic programming languages like PHP), just an HTML file, you can rewrite the URL and add the anchor information:
去B页面
on page B, you need to use JS to get this value, such as:
var username = window.location.hash;
Of course, there are other, such as 隐藏域
. In short, the simplest is SESSION
or COOKIE
.
Session | | Cookies
Session or Cookie
If you do not have a service side and do not consider other security issues, you can place it in a URL.
Server-side do: Session
Client: URL contains parameters, cookies
If only for the front-end page display, can be stored in the following several common places:
1. URL
2. Cookies
3, Localstorage
4, Sessionstorage
Session or Cookie.