[英]Using SessionStorage in javascript to store user context information
Can we use sessionStorage or localStorage of HTML5 to store the user context details to be shared across the different pages? 我们可以使用HTML5的sessionStorage或localStorage来存储要在不同页面之间共享的用户上下文详细信息吗?
Consider a scenario, where i don't have server side storage access at first page, and the user context needs to be passed in later in a header,but before that in whi want to store the user name and his few other context details to be shared with other page. 考虑一种情况,我在第一页没有服务器端存储访问权限,并且用户上下文需要稍后在标头中传递,但是在此之前,要存储用户名和他的其他一些上下文详细信息,与其他页面共享。 Is it recommended to use sessionStorage, cookies or is there any other alternative ?
是否建议使用sessionStorage,cookie或其他替代方法?
sessionStorage is in one tab in site. sessionStorage在站点的一个选项卡中。
sessionStorage.setItem('key', 'test');
go in this tab by site and get param 按站点进入此选项卡并获取参数
sessionStorage.getItem('key');
https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage https://developer.mozilla.org/zh-CN/docs/Web/API/Window/sessionStorage
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.