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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.