remember me upon login
Posted: Sun May 24, 2009 8:06 am
Hello,
I am having trouble with my remember me cookies on my login form.
I have managed to set the cookie (ish) but cannot seem to use it.
When the login form is submitted:
This doesn't seem to be adding the value I am wanting, I want the value to be something like this:
user=USER123+pass=PASS123
But it is showing as
user%3DUSER123+pass%3DPASS123
Why arent the '=' symbols showing?
Now because of this I don't think my code to use the cookie works, In the header of the login page I have got:
and autologin.php is:
Of course I have set:
So hopefully if the cookie is read correctly the page is directed to the myaccount page...
I have been messing around with the codes now for a good 3 hours!!! I feel like im goind round in cirlces so I thought I should ask someone here before I go crazy!!! (First time using cookies by the way)...
Been using http://www.bitrepository.com/php-autologin.html to help me.
I am having trouble with my remember me cookies on my login form.
I have managed to set the cookie (ish) but cannot seem to use it.
When the login form is submitted:
Code: Select all
$_SESSION['user'] = $username;
$post_autologin = $_POST['autologin'];
$value = "user=$username pass=$md5pass";
if($post_autologin == 1)
{
setcookie (RememberMe, $value, time() + 3600 * 24 * 30);
} user=USER123+pass=PASS123
But it is showing as
user%3DUSER123+pass%3DPASS123
Why arent the '=' symbols showing?
Now because of this I don't think my code to use the cookie works, In the header of the login page I have got:
Code: Select all
if (isset($_SESSION['user']))
{
include_once 'autologin.php';
}Code: Select all
<?php
if(isset($_COOKIE[RememberMe]))
{
parse_str($_COOKIE[RememberMe]);
if((user == $username) && (pass == $md5pass)))
{
// Register the session
$_SESSION['user'] = $username;
}
}
?>Code: Select all
if (isset($_SESSION['user']))
{
header("Location: /user/myaccount");
}I have been messing around with the codes now for a good 3 hours!!! I feel like im goind round in cirlces so I thought I should ask someone here before I go crazy!!! (First time using cookies by the way)...
Been using http://www.bitrepository.com/php-autologin.html to help me.