Jump to content


Photo

I have 3 questions about login sessions


  • Please log in to reply
2 replies to this topic

#1 AdRock

AdRock
  • Members
  • PipPipPip
  • Advanced Member
  • 911 posts

Posted 09 August 2006 - 11:48 PM

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
If your topic has been solved, please mark the topic as SOLVED.

This helps others from identifying which topics need help still

#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 10 August 2006 - 12:03 AM

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
Tell me the problem, I will try tell you the solution

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 10 August 2006 - 11:16 AM

2) again using the above var and an if statement

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

I'd use if isset like so:
if(isset($_SESSION["username"])) {
    echo "logout link";
} else {
   echo "log in link";
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users