Jump to content

[SOLVED] auto login help


MDanz

Recommended Posts

$username = $_POST['username'];
    $password = $_POST['password'];

if($username&&$password){
}

else
{

}

where it says else.. i have an user account known as guest. how do i have the guest account already logged in.  i know it Sessions, how do i use sessions to have it logged in as guest if a username and password aren't provided?

 

in simple how do i use session to have it logged in automatically as a user?

i normally do $_SESSION['username']=$username;

 

thats the user logged in, i don't know how to have it logged in without providing a username and password

 

example..

Link to comment
https://forums.phpfreaks.com/topic/174557-solved-auto-login-help/
Share on other sites

it really depends on how you setup your login system. If you are using cookies then you can add a cookie with a username and a password in the else condition, so when your program checks for a member it will find this cookie and use it as a user.

 

if you are using sessions to authenticate your users when they log in, you might want to read how to initiate sessions and how to add variable to this sessions array. check this link: http://au.php.net/manual/en/book.session.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.