× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a little help - facebook login cookie
So here is a little background. I am using UserSpice to setup a webview mobile app. Best practice is to make a user not have to login everytime they use it. I have modified the login to always run the "Remember Me" cookie and that works. However, most people want to use the facebook login. Anyone want to help me figure out how to make the cookie when someone logs in using Facebook. I have tried adding the below to the fb-callback.php right before the redirects

$hash = Hash::unique();
Cookie::put($this->_cookieName, $hash, Config::get('remember/cookie_expiry'));

It did not work. Any suggestions or help please?
fb-callback is where you would do this. I am not sure why exactly it is not working.

This is taken from the User.php Class loginEmail which is what handles the remember. Try including all of this before any redirects on fb-callback.

Here is actually the working code for others needing to do the same thing. It took a good nights rest to figure it out, but user.php is never called so the "$this" construct doesn't exist. The below is pasted before both redirects in fb-callback.php. Hopefully others find it as useful as I do!

$hash = Hash::unique();
$db->get('users_session' , array('user_id', '=', $_SESSION["user"]));

$db->insert('users_session', array(
'user_id' => $_SESSION["user"],
'hash' => $hash,
'uagent' => Session::uagent_no_version()

Cookie::put(Config::get('remember/cookie_name'), $hash, Config::get('remember/cookie_expiry'));
We're planning on overhauling FB and Google OAuth soon-the code is very slapped together and most of it makes no sense-but it is what worked at the time. I will add an option for enabling remember me expiry all the time for OAuth.


Forum Jump:

Users browsing this thread: 1 Guest(s)