I'm creating an external login form in my website and I have a problem with the parameter $lifetime in setCookie() function (from XenForo_Helper_Cookie).
This is the setCookie() function in XenForo_Helper_Cookie:
My login form works perfectly if the checkbox for keep connected is checked, but if the checkbox isn't checked, doesn't work as I want. If isn't checked, the login works but the $lifetime isn't 0.
This is my code:
This is the setCookie() function in XenForo_Helper_Cookie:
PHP:
public static function setCookie($name, $value, $lifetime = 0, $httpOnly = false, $secure = null)
{
$expiration = ($lifetime ? (XenForo_Application::$time + $lifetime) : 0);
return self::_setCookieInternal($name, $value, $expiration, $httpOnly, $secure);
}
My login form works perfectly if the checkbox for keep connected is checked, but if the checkbox isn't checked, doesn't work as I want. If isn't checked, the login works but the $lifetime isn't 0.
This is my code:
PHP:
// In setCookie() I put 0, but apparently doesn't work.
if ($bRemember) {
$dbUserModel->setUserRememberCookie($iUserID);
}
else {
$value = $dbUserModel->getUserRememberKeyForCookie($iUserID);
if (!$value)
{
return false;
}
XenForo_Helper_Cookie::setCookie('user', $value, 0);
}