[英]Updating session in Remix.run using remix-auth
I am using createCookieSessionStorage
and the FormStrategy
to authenticate users using remix-auth
package.我正在使用
createCookieSessionStorage
和FormStrategy
来使用remix-auth
包对用户进行身份验证。 I want to update the session data when a user navigates to another page.我想在用户导航到另一个页面时更新会话数据。 I have a loader function that handles the routing logic via
return redirect('/pageLocation')
.我有一个加载器函数,它通过
return redirect('/pageLocation')
处理路由逻辑。 How do I update the session so that one of the entries becomes { firstVisit: true }
from { firstVisit: false }
?如何更新会话,以便其中一个条目从
{ firstVisit: false }
变为{ firstVisit: true }
}?
Whenever you modify sessions that use cookie storage, you must send the set-cookie
header along with the response.每当您修改使用 cookie 存储的会话时,您必须将
set-cookie
标头与响应一起发送。 This includes redirect
这包括
redirect
return redirect(‘/pageLocation’, { headers: { ‘set-cookie’: await commitSession(session) } })
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.