public static async Task GenerateNewSessionCookiesAsync(this IRequest req, IAuthSession session, CancellationToken token = default) { if (!(req.Response is IHttpResponse httpRes)) { return; } var sessionId = req.GetSessionId(); if (sessionId != null) { await req.RemoveSessionAsync(sessionId, token); } req.Response.ClearCookies(); var tempId = req.Response.CreateTemporarySessionId(req); var permId = req.Response.CreatePermanentSessionId(req); var isPerm = req.IsPermanentSession(); req.AddSessionOptions(isPerm ? SessionOptions.Permanent : SessionOptions.Temporary); session.Id = isPerm ? permId : tempId; req.Items[Keywords.Session] = session; }
public static void GenerateNewSessionCookies(this IRequest req, IAuthSession session) { var httpRes = req.Response as IHttpResponse; if (httpRes == null) { return; } req.Response.ClearCookies(); var tempId = req.Response.CreateTemporarySessionId(req); var permId = req.Response.CreatePermanentSessionId(req); var isPerm = req.IsPermanentSession(); if (isPerm) { req.AddSessionOptions(SessionOptions.Permanent); } session.Id = isPerm ? permId : tempId; req.SaveSessionInItems(session); }