Good way to create session cookie on every route?

const CreateUser: Component<{}> = (props) => {
createServerData$(async (_, { request }) => createOrGetUser(request));

return null;
};

export default CreateUser;
const CreateUser: Component<{}> = (props) => {
createServerData$(async (_, { request }) => createOrGetUser(request));

return null;
};

export default CreateUser;
I just made component like that which i imported to root.tsx, so that it would run on every route. Seems to work but is this good way to do so? Then I just return this in createOrGetUser() on server. (there is other code for database and stuff but return is the important bit)
return json("Cookie set", {
headers: {
"Set-Cookie": await storage.commitSession(session),
},
});
return json("Cookie set", {
headers: {
"Set-Cookie": await storage.commitSession(session),
},
});
0 Replies
No replies yetBe the first to reply to this messageJoin