node.js - after successful login the user is redirected to the home page where the SPA loads. Is using session cookie with JWT a bad idea? -


i have express + postgres backend, , i'm using passport-facebook fb oauth.

if user hits app @ / without having valid token in localstorage, they're taken /login.

my /login page (where you're greeted familiar "continue facebook" message) server rendered (for various reasons). upon clicking button, either verify user if exist , send them session cookie initial jwt, or create new user , send them session cookie initial jwt. in both cases, success condition redirected / , served spa assets.

one of first things spa take jwt session cookie , put localstorage, , deletes cookie.

is terrible approach, or valid in use case?

you using session cookie means store jwt on client. means create server session remain open until expires, spending server resources

session cookies not readable javascript, guess make request server jwt, right?

the process not seem problematic, think optimize sending in redirection process directly jwt in response using regular cookie set-cookie header. cookie stored in client , access directly


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -