Cross-domain sharing of session

encountered a problem. The project uses the separation of front and rear ends, and the back end uses node express . The front end and background are in different places, and there is cross-domain. How to deal with session sharing problem
. My preliminary solution: using database to store session

ask for advice on other methods

Mar.02,2021

if it is a cross-domain problem, your backend can set the response header: Access-Control-Allow-Origin: * to allow all domain names, or you can set it to allow individual domain names

.

deal with session sharing problems: you can save to redis database

you can also take a look at SSO how single sign-on works


after the login is successful, the server generates a signature such as UUID or MD5 based on the unique user name and the current time and returns it to the client, which is used as a custom session_id,. Then the client will bring the session_id, with it every time it requests, and the backend will set a time for the session_id to expire without operation.

Menu