C0py this to moduls/func.php


if (isset($_COOKIE["username"]) && isset($_COOKIE["password"]) && !isset($_SESSION["user"]))
{
$cuser = $_COOKIE["username"];
$cpass = $_COOKIE["password"];
$check = mysql_num_rows(mysql_query("SELECT `username` FROM `b_users` WHERE `username` = '$cuser' AND `password` = '$cpass'"));
if ($check > 0)
{
$_SESSION["user"] = $cuser;
} else {
setcookie("username", "", time()-86400);
setcookie("password", "", time()-86400);
}

}


put it after <?php

after that


Then open /loguser.php, look for $_SESSION["user"]=$username;. under it, paste this code.

$CookieExpire = 200; //The number of days after which the cookie would expire.
$time = 60 * 60 * 24 * $CookieExpire;
$time = time() + $time;
setcookie("username", "$username", "$time");
setcookie("password", "$password", "$time");

change $CookieExpire to the number of your days the cookie would be deleted from the users
browser. And Save!


Then open /logout.php immediately after unset($_SESSION["user"]), paste this..
<?php
setcookie("username", "", time()-86400);
setcookie("password", "", time()-86400);
?>

Download Now
  • Date: Jan 04, 2014

Well users of this code should note that. This code would be 95% effective if the user has cookies enabled on the browser.

So @nonirap u could as well add a cookie detection script which detects if a users browser cookie is on. Otherwise it alerts the visitor.

  • Date: Jan 04, 2014

Also as an addon, you SHOULDN'T store passwords in COOKIE as it can be manipulated or stolen.

You can consider storing a unique id which you check against IP you stored in your db when the visitor returns.

  • Date: Sep 09, 2016


Also as an addon, you SHOULDN'T store passwords in COOKIE as it can be manipulated or stolen.

You can consider storing a unique id which you check against IP you stored in your db when the visitor returns.

Gerardcole

Please How Can I Do That Sir

  • Date: Apr 22, 2018

Why dont you just use sessions.

  • Date: Apr 24, 2019

$string = nl2br ($string);
$string = preg_replace("(\[b\](.+?)\[\/b])is",'<b>$1</b>',$string);

To replace?

  • Date: Apr 24, 2019

Ahdhs is the code just testing

  • Date: Jun 23

First don't store username or password in a cookie, i get u wanna perform autologging, but this is very misleading to upcoming programmers.. as a user can easily manipulate data in a cookie..
Just create and store a rand token in a temp database, each time the user logs in, it creates another random one and update the previous one, this would increase the security a lot..

  • Date: Aug 06

Hey I am currently making chat system signup signin and home page is working but I have a problem on the home page where I used while loop to loop through all the users on my database this where I have the problem where I click on a user name and it will display full information about that particular user