Remember me functionality with Login form

edin1307 13 Jul, 2011
Hi,

I'm using the latest Chronoforms version with Joomla 1.6.
I've created a Jommla registration form without problem using Chronoforms, as well as a Login form.
However I would like to add the 'Remember me' checkbox on the Login Form like the native Joomla Login module.
How can I do that?

Thank you for your answer.
GreyHead 14 Jul, 2011
Hi edin1307,

I tlooks as though this would need either a revised Joomla! Login action for Joomla 1.6 or some custom coding. The code for setting the 'remember me' attribute is in the login() function of com_users/controllers/user.php

Bob
luther 03 Jan, 2012
Hi. I'm also trying to figure out how to implement the "remember me" functionality into my custom made login form. I'd like the form to set the remember me cookie even without the user needing to click a remember me checkbox. I'm using Chrono Forms 4.0 RC2.0 on Joomla 1.5.25.

So far, I've been trying to do this by using some of the code from the login function found in: /libraries/joomla/application/application.php

I've put the following in a custom code action placed inside OnSuccess of Auto Server Side Validation (I couldn't get it to work inside the Joomla Login OnSuccess for some reason):

<?php
jimport('joomla.utilities.simplecrypt');
jimport('joomla.utilities.utility');

$cookieName = 'MY_SECURE_COOKIE';
$hash = JUtility::getHash($cookieName);

//Create the encryption key, apply extra hardening using the user agent string
$key = JUtility::getHash(@$_SERVER['HTTP_USER_AGENT']);

//Encrypt the cookie data
$crypt = new JSimpleCrypt($key);
$rcookie = $crypt->encrypt('the secret data');

$lifetime = time() + 365*24*60*60;
setcookie( $hash, $rcookie, $lifetime, '/' );
?>

After I login with the form, I inspected the cookies set by the site and see that a new cookie has been set which is similar to the one set by the default Joomla login when remember me is checked. It is set to expire in one year, etc.

But, I must have left something out of the code because when I close the browser, re-open it, and reload the site - I am no longer logged in. I'm guessing that I didn't properly tie the code to the user's Joomla session or something along those lines?

Any ideas? Thanks.
GreyHead 03 Jan, 2012
Hi Luther,

I've never tried to do this so probably know less than you do. The obvious difference is in the line
$rcookie = $crypt->encrypt('the secret data');
instead of
$rcookie = $crypt->encrypt(serialize($credentials));


But can you not call the function directly with
$mainframe->login($credentials, $options);
that would save rewriting it.

Bob
This topic is locked and no more replies can be posted.