PHP Cookies in live server do not work but work in Local Host


Question: PHP Cookies in live server do not work but work in Local Host

I have a remember me signed in button where I check if it it set I set php error the cookies for email and password to put them in their fields later on if the user tried to log on and destroy them if the remember me button is unchecked.

         if(isset($_POST["rememberme"])) { //set cookie if checkbox is checked             setcookie ("member_ID",  $userMail, time()+ (86400));             setcookie ("member_Password", $password, time()+ (86400));         }else { //delete cookie if checkbox is not checked             if(isset($_COOKIE['member_ID']) && isset($_COOKIE["member_Password"])) {                 $CookieID = $_COOKIE["member_ID"];                 $Cookiepassword = $_COOKIE["member_Password"];                 setcookie("member_ID", $CookieID, time() - 1);                 setcookie("member_Password", $Cookiepassword, time() - 1);             }         }  

This is the code that puts the cookies in the user input fields

if(isset($_COOKIE['member_ID']) && isset($_COOKIE["member_Password"])){     echo '     <div class="LoginContainer">             <form action="'.$_SERVER["PHP_SELF"].'" method="post">                                     <div class="loginSpacing">                                         <div>                                         <label for="userID" >Email</label>                                         </div>                                         <div>                                         <input id="userID" name="userMail" required value="'.$_COOKIE['member_ID'].'"type="text">                                         </div>                                         </div>                                     <div class="loginSpacing">                                     <div>                                         <label for="Loginpass" >Password</label>                                         </div>                                         <div>                                         <input id="Loginpass" name="Loginpass" required value="'.$_COOKIE["member_Password"].'"type="password" data-type="password">                                     </div>                                     </div>                                     <div>                                         <input id="rememberme" type="checkbox" name="rememberme" value="1" checked = "checked">                                         <label for="rememberme" style="font-size:18px;font-size: 18px;"><span ></span> Keep me Signed in</label>                                     </div>                                     <div>                                         <input type="submit" name="submit" class="SignIn-btn" value="Sign In">                                     </div>                                  </form>     </div>     '; } 

So on the xampp local host it works perfectly. But once I posted it online its not working and I cant php error figure out why. I am sure of the variables $userMail and $password. What can I do or missing to make this work and if you guys have any suggestion to make the mechanism better

Total Answers: 1


Answers 1: of PHP Cookies in live server do not work but work in Local Host

So basically the page Im getting redirected to I added the set cookie php error code from it at the top of the page it worked then