I am building a social media application using nodejs for backend and considering different ways of establishing a "Keep me logged in" functionality.
I have read about the dangers of storing user authentication data in cookies, so I am looking for tricks to ensure user security.
I am considering generating a random token using jsonwebtoken, which encodes a userid and the users IP address. When the user logs into the application the cookie stored in the browser is decoded, if IP address stored in the cookie matches the current IP address of the device, the user logs in automatically.
Would this be safe enough? If not, what are more secure ways of achieving "Keep me logged in" functionality?