用旧的会话ID替换会话ID

时间:2019-07-04 08:52:45

标签: c# asp.net session sessionid

我有一个电子商务,我将购物车与创建该购物车的用户的会话ID一起保存到数据库中,现在我想通过将会话ID替换为数据库中保存的会话ID来恢复它。

我为用户提供了会话ID的链接,当用户单击该链接时,它将带到一个文件,该文件应离开当前会话并用旧会话替换。

我只需要用旧的会话ID替换新的会话ID,该站点就可以从仅具有会话ID的数据库中恢复所有内容。

这里是我现在要做的事情,在台式机上完美运行,在智能手机上,我必须单击两次工作链接

id_session = Request.QueryString["session"];
if (HttpContext.Current.Session["ID_Session"] == null || HttpContext.Current.Session["ID_Session"].ToString() == string.Empty) { HttpContext.Current.Session["ID_Session"] = HttpContext.Current.Session.SessionID; HttpContext.Current.Session["SessionStart"] = "ok"; }

     HttpContext.Current.Session.Abandon();
     if(HttpContext.Current.Session.IsNewSession)     HttpContext.Current.Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", id_session));
        else HttpContext.Current.Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", id_session));
        Response.Redirect("/IT/Carrello",false);

有人可以帮助我吗?

0 个答案:

没有答案
相关问题