简体   繁体   English

用户会话结束时如何保留数据

[英]how to persist data when user session end

currently i working on a system with login module, when a user logged in, a session store information about him will be created. 目前,我正在使用带有登录模块的系统,当用户登录时,将创建一个有关他的会话存储信息。 when session end and user does not check remember me option, page will be redirect to login page with a return URL. 当会话结束且用户未选中“记住我”选项时,页面将重定向到带有返回URL的登录页面。 now there is a problem..... after session expired, and user logged in again, how can i get back the data in previous page? 现在有一个问题.....会话期满后,并且用户再次登录,我如何取回上一页中的数据?

i know there is a view state, but all session expired how i store it to session...? 我知道有一个视图状态,但是所有会话都已过期,如何将其存储到会话中...? currently i just store them in cookie. 目前,我只是将它们存储在cookie中。

is there any better solution i can do to perform this task? 我有什么更好的解决方案可以执行此任务?

You can pass return url in query string. 您可以在查询字符串中传递返回URL。

Response.Redirect("/Account/Login?redirect=/Home/Dashboard");

Edit 编辑

If you are using ASP.NET Web Forms, then you can use ViewState to save form state. 如果使用的是ASP.NET Web窗体,则可以使用ViewState保存窗体状态。 Or alternatively, you can use cookies . 或者,您可以使用cookie But cookies have it's limitations in size. 但是cookie有大小限制。

Another way is also to save data in local storage 另一种方法是将数据保存在本地存储中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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