tags:

views:

68

answers:

2

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, display a captcha.

This doesn't seem to work. :-P

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

$attempt = $this->session->userdata('attempt');
$attempt++;
$this->session->set_userdata('attempt', $attempt);
ocdcoder
Still doesn't work. Shows me 0...
luckytaxi
hrm... edited...try it now
ocdcoder
ah, yea, i had the "++" after the variable...which means it returns the variable and then increments it...if you do ++$attempt it should increment then return the value.
ocdcoder
hot damn that was it! lol ... i was trying "$this->session->userdata('attempt')++ ... lol ... thx
luckytaxi
haha, np, glad to help!
ocdcoder
A: 

hi all this doesn't work for me too :

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