Home
Help
Sitemap
Login
Register
Elxis.org
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: Download Elxis CMS:
Elxis 4.0 Nautilus
Elxis CMS Forum
>
Support
>
General
(Moderators:
Ivan Trebješanin
,
Farhad Sakhaei
) >
if statement for login check? [SOLVED]
Pages: [
1
]
« previous
next »
Print
Author
Topic: if statement for login check? [SOLVED] (Read 1019 times)
ROUBOS
Hero Member
Offline
Posts: 627
if statement for login check? [SOLVED]
«
on:
July 02, 2012, 19: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, 19:32:43 by ROUBOS
»
Logged
webgift
Elxis Team
Hero Member
Offline
Posts: 3263
Re: if statement for login check?
«
Reply #1 on:
July 02, 2012, 19: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, 17:18:06 by webgift
»
Logged
Εlxis Τeam
|
webgift dev
ROUBOS
Hero Member
Offline
Posts: 627
Re: if statement for login check? [SOLVED]
«
Reply #2 on:
July 02, 2012, 19:32:52 »
thank you
Logged
datahell
Elxis Team
Hero Member
Offline
Posts: 7596
Re: if statement for login check? [SOLVED]
«
Reply #3 on:
July 02, 2012, 20: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, 20:15:39 by datahell
»
Logged
Elxis Team
|
Is Open Source
|
IOS Reservations | IOS Eshop
webgift
Elxis Team
Hero Member
Offline
Posts: 3263
Re: if statement for login check? [SOLVED]
«
Reply #4 on:
July 03, 2012, 11:06:51 »
Right Datahell! It was my fault. It's totally recommended the use of either
uid
or
gid
.
«
Last Edit: July 03, 2012, 17:19:06 by webgift
»
Logged
Εlxis Τeam
|
webgift dev
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> News and announcements
-----------------------------
Support
-----------------------------
=> FAQs
=> General
=> Installation
=> Security
=> Administration
=> Database
=> Language
=> Elxis 4.x DEV
=> Elxis 2008 developers guide
=> Technical support
=> Public Speaking
-----------------------------
Extensions
-----------------------------
=> Components
=> Modules
=> Bots and plugins
=> Tools
=> Bridges
=> Templates
-----------------------------
Community
-----------------------------
=> Elxis Community
=> Elxis 2008.x Olympus (dev)
=> Build with Elxis...
-----------------------------
Ελληνικό Forum
-----------------------------
=> Γενικά Θέματα για το Elxis CMS
=> Εγκατάσταση
=> Διαχείριση
=> Γλώσσες - Πολυγλωσσία
=> Πρόσθετα
=> Ασφάλεια
=> Βάσεις Δεδομένων
=> Σχετικά με το Forum
=> Δημόσιο Βήμα
-----------------------------
International zone
-----------------------------
=> Dutch
=> Deutsch
=> Français
=> Italiano
=> Indonesian
=> فارسی - Persian
=> Русский
=> Srpski - Српски
=> Türkiye
Loading...