[SOLVED] isset(), empty() and unset()
Posted: Tue Apr 12, 2005 5:53 am
I am trying to determine whether a session variable exists or not in my code.
If it exists, I want to increment it. If it doesn't, I want to create it. Sounds simple right?
I have tried isset(), unset(), and empty() enough that I think I understand what they do...So, isset() is the logical choice to see if a variable exists. Right? or Not!!
Every time I test this code, is always re-defines $attempt_count and erases the previous values. It's not supposed to do that is it. I 'thought' that session_register() left a variable alone if it was already defined. Does it in-fact re-initialize it?
I even tried just in case I was supposed to address it as a $_SESSION variable, which just shows how confused I am by none of this working.
-------------
Also, the $attempt_count ++; does not seem to work on my main server. I didn't have a problem with it on my local test server, but uploading the script to the main server causes it not to function. I have tried all variations located on the PHP online manual. But, nothing explains why it craps out on the web server.
Any ideas on either of these problems?
Thanks,
If it exists, I want to increment it. If it doesn't, I want to create it. Sounds simple right?
Code: Select all
if (!isset($attempt_count)) {
session_register("attempt_count"); //Counter for shutting down a user after too many login attempts. UNregistered with a successful login
$attempt_count ++;
}Every time I test this code, is always re-defines $attempt_count and erases the previous values. It's not supposed to do that is it. I 'thought' that session_register() left a variable alone if it was already defined. Does it in-fact re-initialize it?
I even tried
Code: Select all
if (!isset($_SESSION[attempt_count]))-------------
Also, the $attempt_count ++; does not seem to work on my main server. I didn't have a problem with it on my local test server, but uploading the script to the main server causes it not to function. I have tried all variations located on the PHP online manual. But, nothing explains why it craps out on the web server.
Any ideas on either of these problems?
Thanks,