WebSite X5Help Center

 
Sam S.
Sam S.
User

Logged In Notifier  en

Author: Sam S.
Visited 2435, Followers 2, Shared 0  

Hello,

When a user is logged in, how do I create in the Header area a notification that says user is logged in.

Like:  "You are logged in as ..."

Thanks,

Sam

Posted on the
5 ANSWERS
Incomedia
Claudio D.
Incomedia

Hello Sam,

You need to add following code in the HTML&Widget Object in the page and not in the header:

<?php

$pa = new imPrivateArea();

$user = $pa->who_is_logged();

echo $user['username'];

?>

This code is necessary to display the username once the use is logged in. It is necessary to have the page extension set to php in step 2 - page properties.

Many thanks!

Read more
Posted on the from Claudio D.
Sam S.
Sam S.
User
Author

Hi Claudio,

Does this mean that I have to add this code to every page?

1.Why can't this be placed on the header?  I see this in numerous websites I log in.  I could go to any page (locked or not) and see this notification that I am logged in and right next to it is LOGOUT.  Can this be done here?

I tried inserting this in the header along with the logout code.  However, they only appear when you are on any locked pages.  But when you go to any UNlocked pages, you get a "fatal error" message, "logout' still appears but your content page disappears.  Or you get this portion of the code: "who_is_logged(); echo $user['username']; ?>" appears and the content page.

2. How do I also add extra words like "You are logged in as:" or "Welcome" Sam S?

3. How do I put a time limit where it will log you off if no activity for X amount of time but gives you a pop up warning with option to continue or log off?

Thanks,

Sam

Read more
Posted on the from Sam S.
Incomedia
Claudio D.
Incomedia

Hello Sam,

The function needs to be in the page where you have the login otherwise, like you noticed, it generates the error since in the other pages the login script is not present.

to add the extra text you can add it directly in the echo line:

<?php

$pa = new imPrivateArea();

$user = $pa->who_is_logged();

echo "You are logged in as: " . $user['username'];

?>

The logoff happens when you use the logout function or the browser has been closed.

It cannot be set with a time limit.

Many thanks!

Read more
Posted on the from Claudio D.
Sam S.
Sam S.
User
Author

Claudio,

1. Can we add select font, type, size, bold, color etc to that?

2. As for time out, can you show us how to do it like your site times us out after a period of inactivity?

Thanks again,

Sam

Read more
Posted on the from Sam S.
Incomedia
Claudio D.
Incomedia

Hello Sam,

To change font type, size and color it will be necessary to use html code where as example you declare it in this way:

<p style="font-size:12px">

<?php

$pa = new imPrivateArea();

$user = $pa->who_is_logged();

echo "You are logged in as: " . $user['username'];

?>

</p>

The automatic logout function after a period of time is not present in the program. You are logged out after the browser has been closed or the logout button has been clicked.

Many thanks!

Read more
Posted on the from Claudio D.