Jump to content

I have 3 questions about login sessions


AdRock

Recommended Posts

I am very new to using sessions so i don't know if it's possible and how to do it.

1st question.
When a user logins to the site, how do i display their name much like in here where you see hello username?
I have a session called $_SESSION['username']

2nd question

I obviously have a link to login.  When the user successfully logs in is there a way of changing the link to logout so there is no option for the user to login again?

3rd question
How would i go about having a 'remember me' so the user doesn't have to login next time they visit the site?

Many thanks for all your help
Link to comment
Share on other sites

1)
You can echo the session
echo $_SESSION["username"];

2) again using the above var and an if statement

if($_SESSION["username"]){
echo "logout link";
}else{
echo "log in link";
}

3)
Use cookies
and set the field data, then on log in page, call the cookie, if its there complete the form with the info in the cookie
Link to comment
Share on other sites

[quote]2) again using the above var and an if statement

if($_SESSION["username"]){
echo "logout link";
}else{
echo "log in link";
}
[/quote]
I'd use if isset like so:
[code=php:0]if(isset($_SESSION["username"])) {
    echo "logout link";
} else {
  echo "log in link";
}[/code]
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.