Welcome,
Guest
.
Please
login
or
register
.
Did you miss your
activation email
?
News:
Elxis documentation
for users and developers.
Home
Help
Login
Register
Elxis CMS Forum
»
Support
»
General
(Moderators:
Ivan Trebješanin
,
Farhad Sakhaei
) »
if statement for login check? [SOLVED]
« previous
next »
Print
Pages: [
1
]
Author
Topic: if statement for login check? [SOLVED] (Read 4944 times)
ROUBOS
Hero Member
Posts: 699
if statement for login check? [SOLVED]
«
on:
July 02, 2012, 20:15:40 »
Hi,
I've used the if statement to check if we're on a certain component page in order to display or hide part of the template, is there an if statement to check wether the user is loged on and display a logout button?
I want to use a login and a logout button. So that when the user is loged on, then the logout button appears.
any thoughts???
thanks.
«
Last Edit: July 02, 2012, 20:32:43 by ROUBOS
»
Logged
webgift
Elxis Team
Hero Member
Posts: 4193
Re: if statement for login check?
«
Reply #1 on:
July 02, 2012, 20:27:49 »
Hi Roubos,
Yes you can do that with this way :
if ($my->id) {
echo '<img src="logout.png" alt="Log out" width="300" height="50" />'."\n";
} else {
echo '<img src="login.png" alt="Log out" width="300" height="50" />'."\n";
}
In case that you are going to include the above piece of code at the index.php file of your template then there is no need to define the global variable $my. In any other case you should define it like this :
global $my;
On Elxis Nautilus relative way :
if (eFactory::getElxis()->user()->gid != 7) {
echo '<img src="logout.png" alt="Log out" width="300" height="50" />'."\n";
} else {
echo '<img src="login.png" alt="Log out" width="300" height="50" />'."\n";
}
*Set the exact width and height of your image source inside img tag.
«
Last Edit: July 03, 2012, 18:18:06 by webgift
»
Logged
Elxis Team •
Custom web design [EN]
-
[EL]
•
.GR Registrar
ROUBOS
Hero Member
Posts: 699
Re: if statement for login check? [SOLVED]
«
Reply #2 on:
July 02, 2012, 20:32:52 »
thank you
Logged
datahell
Elxis Team
Hero Member
Posts: 10356
Re: if statement for login check? [SOLVED]
«
Reply #3 on:
July 02, 2012, 21:12:57 »
Checking access
level
value, to determine if a user is logged in or not, is not always safe on Nautilus.
You better check
uid
(user id, greater than zero for elxis users) or
gid
(group id, unequal to 7 - guests- and optionally to 6 - external users).
Conclusion
$elxis->user()->uid > 0 The user is logged in via Elxis Authentication.
$elxis->user()->uid = 0 The user is a guest or logged in via external authentication provider (LDAP, twitter, gmail, etc).
$elxis->user()->gid == 7 The user is a guest
$elxis->user()->gid == 6 The user is logged in via external authentication provider.
else the user is logged in via Elxis authentication.
«
Last Edit: July 02, 2012, 21:15:39 by datahell
»
Logged
Elxis Team
|
Is Open Source
|
IOS Rentals | IOS AERO
webgift
Elxis Team
Hero Member
Posts: 4193
Re: if statement for login check? [SOLVED]
«
Reply #4 on:
July 03, 2012, 12:06:51 »
Right Datahell! It was my fault. It's totally recommended the use of either
uid
or
gid
.
«
Last Edit: July 03, 2012, 18:19:06 by webgift
»
Logged
Elxis Team •
Custom web design [EN]
-
[EL]
•
.GR Registrar
Print
Pages: [
1
]
« previous
next »
Elxis CMS Forum
»
Support
»
General
(Moderators:
Ivan Trebješanin
,
Farhad Sakhaei
) »
if statement for login check? [SOLVED]