How to Auto login to a website by setting header in node js response

682 Views Asked by At

We are validating user by Rest API if user is valid then Rest call will return one cookie object that include some token and then we have to redirect user to another url so by setting header with that cookie so that user will be able to login automatically without prompting login window. How we can do this thing, we are using Node JS

1

There are 1 best solutions below

2
On

From my understanding of your question, you wish to authenticate a user and redirect them to another url when they've been authenticated. If so, you can try using sessions.

With sessions, you can securely store cookie variables for a period of time that you can check for on your pages that require user login. That way, pages that require authentication can be loaded without prompting the login window/page. An example of a variable you can set would be isUserLoggedIn: true.

Here's a tutorial for using sessions with Express.js.