new_php Posted April 19, 2007 Share Posted April 19, 2007 Hello to all once again! in need of your help once more! i am trying to add a cookie that will count the failed logins on my forms! and when up to three failed logins would no longer be accessible for lets say five minutes. here is what i have so far! <?php if ( !isset($_COOKIE["nbVisite"] ) ) { setCookie( "nbVisite", 1 , time() + 3600 * 24 * 30 ) ; } else { setCookie( "nbVisite", $_COOKIE["nbVisite"] + 1 , time() + 3600 * 24 * 30 ) ; } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Exercise pratique 3b</title> </head> <body> <?php if (! isset($_POST["nom"])) { if (! isset($_POST["mdp"])) { if ( $_GET["nom"] == "david") { if ( $_GET["mdp"] == "abc123") { echo "<h3>Authentification réussie! Bienvenue david!</h3>"; } else { echo "<h3>Authentification échouée! Veuillez ré-essayer!</h3>"; } } } } ?> now this checks for the right username and password and displays 2 messages either the congrats message or the failed login one. now with the new cookie i need help to created id write up a third message. all your help is very appreciated. thanks in advance! Link to comment https://forums.phpfreaks.com/topic/47670-cookies-help/ Share on other sites More sharing options...
Guest prozente Posted April 19, 2007 Share Posted April 19, 2007 The client can deny to accept cookies and this would defeat the purpose of your code. It sounds like you're trying to stop bruteforcing. You should store this information server side in order to be some what effective. Link to comment https://forums.phpfreaks.com/topic/47670-cookies-help/#findComment-232790 Share on other sites More sharing options...
new_php Posted April 19, 2007 Author Share Posted April 19, 2007 thanks for pointing this out! and i understand it! but i would still like to be able to write the code =) Link to comment https://forums.phpfreaks.com/topic/47670-cookies-help/#findComment-232792 Share on other sites More sharing options...
new_php Posted April 19, 2007 Author Share Posted April 19, 2007 bump! any help? Link to comment https://forums.phpfreaks.com/topic/47670-cookies-help/#findComment-233094 Share on other sites More sharing options...
cyrilsnodgrass Posted April 19, 2007 Share Posted April 19, 2007 I don't think you can extract values from a cookie on the same page it is set. You may need to change your approach so that all of your input for the login data is on one form and have a submit button pointing to an action form that will extract the cookie data and process it. Also if you are incrementing the cookie value you need ++ instead of +. I am a noobster though so don't take this as 100% correct ! Link to comment https://forums.phpfreaks.com/topic/47670-cookies-help/#findComment-233116 Share on other sites More sharing options...
new_php Posted April 19, 2007 Author Share Posted April 19, 2007 the thing is i have another page that's pulling the data from the form entries. this is my 2nd page where it processes the data! thanks for your input though =) bump! Link to comment https://forums.phpfreaks.com/topic/47670-cookies-help/#findComment-233126 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.