Open
Description
Description
I am trying to rebuild the Hacker news web app, without using a database, and store user information (username) in cookies. Using a model similar to yours, I am currently able to add the username to the cookie header, but I am unable to delete. Here is the code for the login page, specifically the action that adds the cookie:
export async function action({ request }) {
const session = await getSession(request.headers.get("Cookie"));
const form = await request.formData();
const username = form.get("name");
const Password = form.get("password");
// Login succeeded, send them to the home page.
return redirect("http://localhost:3000/", {
headers: {
"Set-Cookie": username,
},
});
}
And here is the logout page:
import { ActionFunction, redirect } from "@remix-run/node";
import { getSession, destroySession } from "~/sessions";
export const loader: ActionFunction = async ({ request }) => {
const session = await getSession(request.headers.get("Cookie"));
//await destroySession(session);
return redirect("/login", {
headers: { "Set-Cookie": await destroySession(session) },
});
};
Is there anything that I might be missing?
Metadata
Metadata
Assignees
Labels
No labels