This forum is archived. Posts are preserved for historical reference. For current help, join us on Discord.

[Help] Login directly without type password?

In UserSpice 4.4 · Started by stonez56 on 2019-04-16 3:53 am · 20736 views · 7 replies

Hi All,
I used UserSpice 4.4 in a sub-system within a fairly large portal system.
Now, I was asked to only authenticate once when users logged into the portal to be able to use the sub-system.
In other words, I couldn't ask user to login to UserSpiece in this sub-system again once they logged in to the portal.

I needed the permission by page features and would like to keep use UserSpice.
What's the best way to do this?

Here is what I came up with:

1.) User login to portal
2.) Get the "username" from the portal
3.) Use that "username" to automatically login to UserSpiece (without user typing ID, password again)
4.) Continue to use all features in UserSpiece 

Is this feasible?  How should I do this?

Thanks!

Stonez56
Hi Stonez, I'm not sure exactly if I'm following, but the idea of being "logged in" to userspice is actually a lot simpler than it sounds.

Every time a userspice page loads session_start() is called in the init file and when you login, if your user id is one, logging in just sets $_SESSION['user'] = 1; So it really doesn't matter how you get to that point. You can login with username or email. You can get google or facebook to confirm your identity or you can even have another app on the same server do it.

Hi Stonez, I'm not sure exactly if I'm following, but the idea of being "logged in" to userspice is actually a lot simpler than it sounds.  

Every time a userspice page loads session_start() is called in the init file and when you login, if your user id is one, logging in just sets $_SESSION['user'] = 1;   So it really doesn't matter how you get to that point.  You can login with username or email. You can get google or facebook to confirm your identity or you can even have another app on the same server do it.

Thank you for the quick reply! 
I looked into the $_SESSION and it does have $_SESSION['user'] = 1
Now, I don't have to worry whether I am FULLY logged-in with all the required parameters for UserSpice or not... :)

By the way, what's the proper way to log-out a user?

Would this $_SESSION['user'] = 0 enough?

Thank you,
Stonez56
Awesome! Glad it helped!
By the way, what's the proper way to log-out a user?

Would this $_SESSION['user'] = 0 enough?

Stonez56
Usually just
session_destroy();
Redirect::to('index.php');

Usually just
session_destroy();
Redirect::to('index.php');



Right, I forgot the need to destroy the session! 

Thank you!
Stonez56
No problem!