close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

MySQLi Log In User - How to detect if a user is logged in and how to hide certain content based on that (not auth levels)

Thread began 10/03/2014 7:31 am by Nathon Jones Web Design | Last modified 10/03/2014 9:53 am by Jason Byrnes | 1693 views | 5 replies |

Nathon Jones Web Design

MySQLi Log In User - How to detect if a user is logged in and how to hide certain content based on that (not auth levels)

I need to display either a "Sign in" button or a "Log Off" button depending on whether or not a user is logged in or not.
Can this be done considering I've built the whole thing in MySQLi?

Thank you
NJ

Sign in to reply to this post

Jason ByrnesWebAssist

When you create the login behavior, the First setting on the general tab is the login name.

On login success a session variable is created using the login name as:
WA_AUTH_<login name>

so for example if you name the login "MyLogin", the session will be created as
WA_AUTH_MyLogin

you can create an if statement to check for that session variable and show logged in or not logged:

<?php
@session_start();
if(isset($_SESSION['WA_AUTH_MyLogin'])) {
?>
Logged In
<?php } else { ?>
Not Logged In
<?php } ?>
Sign in to reply to this post

Nathon Jones Web Design

Receiving a Parse error with that code:

Parse error: syntax error, unexpected 'if' (T_IF) in C:\inetpub\wwwroot\smt\smtadmin\navbar.php on line 27

Line 27 is:
if(isset($_SESSION['WA_AUTH_USER'])) {

Thank you.
NJ

Sign in to reply to this post

Jason ByrnesWebAssist

sorry, forgot the semi colon at the end of the session_start line.

that line should be:
@session_start();

Sign in to reply to this post

Nathon Jones Web Design

Thank you. That's fixed it.

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...