Store information per logged-in user without using Session

Asked

Viewed 31 times

0

I would like to know how I can store user information individually without using Constants and Session to be accessed by my data access project?

It used constants but the application was transformed into Saas and constants ended up giving conflict if there was more than one user logged in at the same time.

The goal is to store a dynamic string Connection per user to be used by the data access layer.

  • if you are not going to use Session you need to use a database, and for example a token that will serve as a user session id

  • But I need to access this string Connection to know which database to connect to, not use a database

  • 1

    At least you need a "Energy" bank to save sessions, then you can use that to decide what to do, like open a specific connection. It is a bit confusing, without more details becomes difficult to help, the fact is: to keep a logged-in user session you will need to save it in one place, and it could be a "session database"

  • I understood, and there would be no other way to do that?

  • There are several approaches, but to be able to give an answer you need to present a [MCVE]

1 answer

1

Really, if you’re thinking about user security, having a databank and token manager would be a good practice.

But, dude, if your focus is not security, and in order to solve your problem, one solution (which is not good but works) is to store the users who are logged in to the localSotorage and use a socket to update each users' logs when any log in, or some log in.

Some points worth highlighting:

  • if your application is to have many users, this solution will become unviable;
  • a way to put a little security on it would be to encrypt the data in some way (with key provided by the server), I suggest using bcrypt;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.