logo
Ask your Symfony questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$5
How can I manually call Remember Me?

I'm helping a client integrate a site with JanRain RPX. We want people to stay logged in for awhile.

If the user logs in the normal way, using the signinSuccess.php form that comes with sfGuardUserPlugin. And if people click the RememberMe button, they stay logged in for a long time. I'm trying to figure out how I can trigger "RememberMe" manually.

I'm using this code handling JanRain RPX:


$user = sfGuardUserPeer::retrieveByUsername($email);
if (get_class($user) == 'sfGuardUser') {
$this->getUser()->signin($user);
$this->setFlash('notice', 'You are logged in');
$this->forward('user', 'home');
return sfView::SUCCESS;
}


This code works great, but it does not seem to trigger RememberMe. I need to figure out a way to make that happen.

Basically, I want to set the RememberMe cookie, which seems easy to do from action code, but I assume I can not do this in the action code, since that comes too late in the overall process, yes?

In sfGuardRememberMeFilter.class.php I do not see a cookie being set, so I assume the code that sets the cookie is elsewhere. But where? And what value is used to set this cookie?

This question has been answered.

Lawrence Krubner | 07/26/10 at 5:43pm Edit


(3) Responses

See a threaded view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    07/26/10
    5:58pm
    Joan Teixidó says:

    The RememberMe just register in database a hash to compare with a cookie saved in client (and the IP and user_id too).

    So, in JanRain RPX i don't know if you can make a query to database if the actual user has a cookie with the correct hash.

    I'm not sure if this can help you

    joan

  • avatar
    Last edited:
    07/27/10
    10:14am
    JuG says:

    Hi,


    Just call the sfGuardSecurityUser::signIn with an extra parameter :


    $user = sfGuardUserPeer::retrieveByUsername($email);

    // Please note the use of "instanceof" in the condition
    if ( $user instanceof sfGuardUser )
    {
    $this->getUser()->signin( $user, true ); // TRUE means "remember me"
    $this->setFlash('notice', 'You are logged in');
    $this->forward('user', 'home');
    return sfView::SUCCESS;
    }



    For more details, see sfGuardPlugin code source


    Julien

    Previous versions of this answer: 07/27/10 at 2:06am

  • avatar
    Last edited:
    07/27/10
    2:16am
    Loban Rahman says:

    JuG is perfectly right.

This question has expired.





Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.