Sessions...

From: Date: Wed, 14 Aug 2002 18:34:59 +0000
Subject: Sessions...
Groups: php.general 
Request: Send a blank email to php-general+get-112575@lists.php.net to get a copy of this message
<? setcookie("cookie", "Job Postings Psyc... Created by Kondwani Mkandawire", time()+3600); session_start(); session_register("MySession"); $counter=0;?> <?php $file = fopen(basename($PHP_SELF), "r+"); if((SomeCondition is Satisfied)&&($counter < 4)){ echo '<form name="formName" action = "ThisSamePHPFile.php" method="post">'; if(empty($verif)){ Display Some message... $counter++; fputs($file, "<?\r\nsetcookie(\"cookie\", \"Created by Kondwani Mkandawire\", time()+3600);\n"); fputs($file, "session_start();\n"); fputs($file, "session_register(\"MySession\");\n"); fputs($file, "\$counter=$counter;?>\r\n"); } else{ Display SomeOther message... $counter++; fputs($file, "<?\r\nsetcookie(\"cookie\", \"Created by Kondwani Mkandawire\", time()+3600);\n"); fputs($file, "session_start();\n"); fputs($file, "session_register(\"MySession\");\n"); fputs($file, "\$counter=$counter;?>\r\n"); } } else{ reset counter to 0 destroy session... } I want this set up such that given someone hits the close button on the browser, the counter is set to 0... Coz at the moment if someone gets fed up of trying and closes the browser, the next person has less than 4 attempts to login in... Any idea of how I can go about using this sessions idea coupled with the self modifying code to achieve this? I can't exactly stick in an: if(session_is_registered) statement, coz it appears as though the session is restarted every time the code is modified..

« previous php.general (#112575) next »