Closed Superheld closed 2 years ago
Hello, if you want to get the id of the currently logged-in user, you can use this:
$this->ion_auth->user()->row()->id;
and it applies to each attribute in table, like first_name, active (status), email.
Are there any drawbacks to retrieving the user id from the session? $_SESSION['user_id'] ?
Are there any drawbacks to retrieving the user id from the session? $_SESSION['user_id'] ?
Even though it is used by the library, by accessing it you have no certainty that the user_id is created by Ion Auth
Ah, and yet, if I change the $_SESSION['user_id'] value, IonAuth starts to think I am a different user :) So I guess that variable is all the memory that IonAuth has of the logged in user in a particular session...
Hey, the only downside to grabbing it from the session directly is that you won't know if the user's account has been deactivated or deleted.
Hi out there!
I'm struggling with the simple question "how to get user id"... :)
As I saw in the documentation user() should return everything of the logged in user. But if I do a print_r() on this, I only see my configuration an that kind of stuff. What do I misunderstood?
Thats how I used it:
` $this->ionAuth->user()->user_id $this->ionAuth->user()->id $this->ionAuth->user()
$this->ionAuth->loggedIn() ` last line work, so model is loaded and I can use it. Just to say this too :-)
Thank to all here and have a nice 2022 ;-)