开发者

Forum submit timelimit for CodeIgniter?

This is the code I'm using inside codeigniter controller, that doesn't seem to work 开发者_开发问答for me. contact.php = controller

function send()
{
$this->load->library('session');

$this->session->set_userdata('lastsent', microtime());

if(microtime() >= $this->session->userdata('lastsent') + 60000000)
{
// here I have all my send email code, that works.
...
$data['message'] = 'Email was sent, thank you.';
$this->load->view('contact', $data);
}
else
{
$data['message'] = 'Please wait 60 seconds.';
$this->load->view('contact', $data);
} //timeout check

} //send()


You forget to add your data in the session :

$this->session->set_userdata('lastsent', 'Your data here');

eg :

$this->session->set_userdata('lastsent', microtime());

Edit : Try using time() instead of microtime() (microtime is not supported everywhere, time is) function send()

{
    $this->load->library('session');

    $this->session->set_userdata('lastsent', time());

    if(time() >= $this->session->userdata('lastsent') + 60)
    {

        $data['message'] = 'Email was sent, thank you.';
        $this->load->view('contact', $data);
    }
    else
    {
        $data['message'] = 'Please wait 60 seconds.';
        $this->load->view('contact', $data);
    } 

}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜