MVC Handling a CorpId for the site

前端 未结 1 366
天涯浪人
天涯浪人 2021-01-25 08:21

I\'m not sure I\'m handling this the right way, but since I\'m running into issues, I assume I\'m not.

I have to have a corporation id sent in when loading the login scr

相关标签:
1条回答
  • 2021-01-25 08:46

    You need to create a separate cookie that identifies the Corporate ID that doesn't expire with user's session. Session["CorpId"] will expire with the user session and won't work.

    var corpCookie = new HttpCookie("CorpID", id);
    corpCookie.Expires = DateTime.Now.AddDays(30.0);
    HttpContext.Current.Response.Cookies.Set(corpCookie);
    

    Each time the user logs in, you could update the expiry to make it a sliding expiration. To retrieve the cookie value, use the following:

    var corpID = HttpContext.Current.Request.Cookies.Get("CorpID").Value;
    
    0 讨论(0)
提交回复
热议问题