I have a login script in which I want to set a cookie. A cookie should be set only if a user checks the box, Remember Me.
When I run my script, I'm receiving a blank page. I tried placing the code in different places within the script and the result is always the same.
Can someone take a look at my script and help me set my cookie properly?
Thank you very much.
Here's the script:
<?php
session_start();
header("Cache-control: private");
include "conn.inc.php";
switch($_REQUEST['req'])
{
case "validate":
$validate = mysql_query("SELECT * FROM member WHERE
username = '{$_POST['username']}' AND password = md5('{$_POST['password']}')") or
die (mysql_error());
I was able to get the setting of the cookie to work.
Here's what I want to do and I can't get this to work. On the login page, a user can check a box so that the next time they login they will be remembered. In the form, I have: <input type="checkbox" name="remember" value="Yes">.
In theory, if I wrote the following statement, the information for the user should be remembered, but it's not:
if ($_POST[remember] == "Yes")
{
setcookie('member', 'member', time()+24*3600*60);
}
How could I modify my script to make the above statement to work? Should I include a field in my database table that will flag who wants to or not wants to be remembered and then set the cookie? I'm not sure. The code on the bottom doesn't include the above statement because no matter where I stick it, it won't work.
Thanks for the help.
Here's the script:
<?php
session_start();
header("Cache-control: private");
include "conn.inc.php";
switch($_REQUEST['req'])
{
case "validate":
$validate = mysql_query("SELECT * FROM member WHERE
username = '{$_POST['username']}' AND password = md5('{$_POST['password']}')") or
die (mysql_error());
Bookmarks