This is the code I have for creating the cookies
$login_submit = (isset($_POST['login'])) ? true: false;
$login_remember = (isset($_POST['remember']) && $_POST['remember'] == 1) ? true: false;
$login_email = isset($_COOKIE['login_email']) ? $_COOKIE['login_email'] : request_var('login_email', '');
$login_password = isset($_COOKIE['login_password']) ? $_COOKIE['login_password'] : request_var('login_password', '');
if (!logged_in())
{
if ($login_submit)
{
if ($login_remember)
{
//setcookie('imgit_logged_in', 1, time()+31556952);
setcookie('login_email', $_POST['login_email'], time()+60*60*24*365, '/');
setcookie('login_password', md5($_POST['login_password']), time()+60*60*24*365, '/');
}
//Code continues here,but irrelevant for my problem so I won't post it.
And of course this is the HTML form:
<form method="post" action=""> <strong class="normal">E-mail:</strong> <input type="email" name="login_email" maxlength="255" class="input_fields" placeholder="Your E-mail" required /> <strong class="normal">Password:</strong> <input type="password" name="login_password" maxlength="35" class="input_fields" placeholder="Your Password" required /> <strong class="normal"><input type="checkbox" name="remember" value="remember">Remember</strong> <input type="submit" name="login" class="button-small" value="Log in" /> <strong class="normal pointer" id="close_login">X</strong> </form>
And that's what I have to access the cookie:
else if (empty($login_errors) && !$register_submit && logged_in() && !isset($_COOKIE['imgit_note']) || isset($_COOKIE['login_email']) && isset($_COOKIE['login_password']))
{
echo '<div class="info" id="welcome_back">Welcome back <span class="capitalize">' . get_username() . '</span>, now upload some pics or try out our tools.';
echo '<span class="pointer right" title="Dismiss forever" onclick="setCookie(\'imgit_note\', \'1\', 365); $(\'#welcome_back\').fadeOut(\'fast\');">X</span>';
echo '<span class="pointer right" title="Dismiss" onclick="$(\'#welcome_back\').fadeOut(\'fast\');">✔</span> </div>';
}
The cookies aren't being created when clicking remember me! don't know what I did wrong.. :\
btw I know that storing the pass and email in the cookie isn't the best idea,but I just want to get it to work now and will take care of security later.
Thanks a lot.

New Topic/Question
Reply



MultiQuote







|