Login   Register  
PHP Classes
elePHPant
Icontem

Cookies

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Secure Session  >  All threads  >  Cookies  >  (Un) Subscribe thread alerts  
Subject:Cookies
Summary:Remember User button and cookie check
Messages:2
Author:carrucola
Date:2009-01-07 09:20:27
Update:2009-01-08 19:13:13
 

  1. Cookies   Reply  
Picture of carrucola
carrucola
2009-01-07 09:20:28
Hi All, Great Script!
How I can add the Remember me function?

I need to check the cookies and check if the cookie is set and correct.

Do you think is correct a call to a function that do this on your check function?

Like this:


function checkCookie()
{
if (isset cookie['remember'] && (..check the value of cookie))
{return true;}
else
{return false;}
}

// Call this to check session.
function Check()
{
$this->_RegenerateId();
if (isset($_SESSION['ss_fprint']) && $_SESSION['ss_fprint'] == $this->_Fingerprint())
{return true;}
else if (!isset($_SESSION['ss_fprint']))
{
if (checkCookie())
{
// start the session
$_SESSION['ss_fprint'] = $this->_Fingerprint();
}
}
}

  2. Re: Cookies   Reply  
Picture of Vagharshak Tozalakyan
Vagharshak Tozalakyan
2009-01-08 19:13:13 - In reply to message 1 from carrucola
Hello,

I don't know how your script is organized, but typically you may need to call $ss->open() after checking the validity of the cookie.

Something like this:

$ss = new SecureSession();
....

if (isValidCookie()) {
$ss->open();
$_SESSION['validUser'] = true;
redirectToProtectedPage();
}

if (isset($_POST['login'])) {
if (isValigLogin()) {
$ss->open();
$_SESSION['validUser'] = true;
redirectToProtectedPage();
}
}