Jump to content

Cookies help!


new_php

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.