+ 1

PHP cookies are not working on live server

I'm having a hard time with PHP cookies. I have tested my code on the local server and it seems to be working as expected but when I'm testing my code on the live server, everything is working fine but cookies. I tried everything( including StackOverflow) but it seems not to be working. //these two lines are not executing at all on live server setcookie("_login",$_COOKIE['_login'] = $_POST['email'], time()+2595600, "/"); setcookie("_password",$_COOKIE['_password'] = $_POST['password'], time()+2595600, "/"); if(!empty($_POST['rem'])) //if the button is checked { setcookie("member_login",$_POST['email'],time()+2595600); setcookie("member_password",$_POST['password'],time()+2595600); } What am I doing wrong? Any suggestion would be highly appreciated.

10th Jul 2018, 6:07 PM
####
#### - avatar
6 Respostas
+ 1
Remove the COOKIE superglobal. And learn how to sanitize inputs.
10th Jul 2018, 6:09 PM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
+ 1
Can you put the code without COOKIE in here too? Preferably in a PlayGround link.
10th Jul 2018, 9:01 PM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
0
Ben Allen (Njinx) I tried without COOKIE superglobal but it didn't work either. Here I'm not talking about how to sanitize user input. I just gave a sample of my code snippet so don't need to comment on that.
10th Jul 2018, 6:25 PM
####
#### - avatar
0
I have updated without COOKIE
11th Jul 2018, 6:56 AM
####
#### - avatar
0
Suvojit@007 Did you upload it here?
11th Jul 2018, 12:33 PM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
0
@Ben I have updated my answer. if(!empty($_POST['rem'])) //if the button is checked { //NOT WORKING AT ALL setcookie("member_login",$_POST['email'],time()+2595600); setcookie("member_password",$_POST['password'],time()+2595600); }
11th Jul 2018, 12:53 PM
####
#### - avatar