Skip to main content

Implementing user login

The login flow authenticates existing users in your application. This guide shows how to implement a secure login process that authenticates users and creates sessions.

app.get("/", (req, res) => {
ory
.toSession({ cookie: req.header("cookie") })
.then((data) => res.json(data))
.catch(() => res.redirect(`${baseUrl}/ui/login`))
})

After successful login

Ory:

  1. Creates a session for the user
  2. Sets a secure session cookie in the browser
  3. Redirects the user to the specified return URL or default location

Your application should then check for the presence of this session cookie to determine if a user is authenticated.