
Originally Posted by
thetestingsite
Now that you are getting the login success message, add what you tried to add before (the setcookie items.)
That may not be the best way to do it. I would use something along these lines.
Log them in
PHP Code:
@session_start();//Start the session, Must be called before anything is sent to the browser
$_SESSION['user'] = $username;//Remember the username
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];//Remember the IP.Another line of defense against the session getting hijacked
and check the login
PHP Code:
@session_start();//Must be called before anything is sent to the browser
if(!empty($_SESSION['user']) && !empty($_SESSION['ip']) && $_SESSION['ip'] == $_SERVER['REMOTE_ADDR']){
echo 'User is logged in';
}
Bookmarks