Jump to content

Making Welcome Message, Persistent


doubledee

Recommended Posts

I am adding a "Welcome Message" in my Header file - which is included in every page on my website.

 

If the user is logged in, they would see something like, "Welcome, Debbie!!

 

What is the best approach to take with storing (and checking) the "LoggedIn Status" and "User's Name"?

 

Do I just store them both in a SESSION and access them?

 

Or should I be checking for these two values from my back-end database?

 

It seems to me that a couple of weeks ago I got into some big debate with people about "persistence" and whether it was okay of not to store information in the SESSION...

 

What do you think?

 

Thanks,

 

 

Debbie

 

 

Link to comment
Share on other sites

sessions are the way to go

 

Ones someone logged in(1 time you contact the database, and check credentials), you store that in a session . So adding Welcome Debbie, can be just as easy as a simple check.

Is debbie logged in if so echo hello debbie

Link to comment
Share on other sites

sessions are the way to go

 

Ones someone logged in(1 time you contact the database, and check credentials), you store that in a session . So adding Welcome Debbie, can be just as easy as a simple check.

Is debbie logged in if so echo hello debbie

 

So in my "log_in2.php", after I authenticate the user, I currently set...

$_SESSION['loggedIn'] = TRUE;
$_SESSION['memberFirstName'] = $memberFirstName;

 

So is it okay to just have something like this in my header file...

 

<?php
$firstName = (isset($_SESSION['memberFirstName']) ? $_SESSION['memberFirstName'] : '');

if ($_SESSION['loggedIn'] == TRUE){
	// Member Welcome.
	echo '<p id="welcome">
		<span class="orangeBold">Hello, ' . $firstName . '!!</span>
		</p>';
}else{
	// Visitor Welcome.
	echo '<p id="welcome">
	<span class="orangeBold">Hello,</span> <a href="#">Sign In</a> to access member-only features and content.
									  Not a Member?  <a href="#">Start Here</a>
	</p>';
}
?>

 

 

Debbie

 

 

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.