I am trying to implement a login scheme where I keep a count on the number of attempts the user tries , this is for security reasons . My code is :
{
ob_start();
$_SESSION['attempts'] = 0;
$_SESSION['sleep'] = 0;
$_SESSION['ip']=$this->get_ip_address() ;
$login = new User('login');
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
if(isset($_POST['yt0']))
{
$login->Username = ($_POST['User']['Username']);
$salt = $login->getSaltByUsername($login->Username) ;
$login->SecretCode = $this->hasher($login->Username,($_POST['User']['SecretCode']),$salt);
var_dump($_SESSION) ; /*First Dump , gives all session variables correctly*/
echo $_SESSION['attempts'] ;
Yii::app()->user->setState('attempts', $_SESSION['attempts']++);
var_dump($_SESSION) ;
I am getting the PHP Notice : "Undefined index: attempts "
However in the first dump as well as the echo i am getting the correct number of attempts . What am I doing wrong here ?