I am using createCookieSessionStorage
and the FormStrategy
to authenticate users using remix-auth
package. 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')
. How do I update the session so that one of the entries becomes { firstVisit: true }
from { firstVisit: false }
?
CodePudding user response:
Whenever you modify sessions that use cookie storage, you must send the set-cookie
header along with the response. This includes redirect
return redirect(‘/pageLocation’, { headers: { ‘set-cookie’: await commitSession(session) } })