开发者

Increment session variable by one

How the heck do I increment a variable that's inside a session? If I declare $attempt, each time a user unsuccessfully attempts to login, I want $attempt to increase by 1. In the event it gets to 3, di开发者_StackOverflow社区splay a captcha.

This doesn't seem to work. :-P

$this->session->set_userdata('attempt',$this->attempt++);



$attempt = $this->session->userdata('attempt');
$attempt++;
$this->session->set_userdata('attempt', $attempt);


<?php
    $visit=1;
    $view='select * from user_log where id='.$_SESSION['id'];
    $viw=mysql_query($view);
    while($row=mysql_fetch_assoc($viw)){
    $name = $row['name'];
    $visit += $row['visit'];
    $vst = $row['visit'];
    }
    if(!$_SESSION['visit']){
        $update = 'update user_log set visit='.$visit;
        mysql_query($update);                            
        $up_view = $name." you visited ".$visit;         
        $_SESSION['visit']=1;                            
        }
        else                                             
        {
            $up_view = $name." you visited ".$vst;
        }


?>


After declaring $this->session->userdata('attempt', 0); you can increment the session value using the following code.

$this->session->attempt++;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜