HI,
I hope someone can help. I'm trying to show the username of the logged in user on this menu.inc page and certain pages only when logged in.
The result I have with the code below is no username showing, just "Hi !" (the "login" link disappear as planned) and all pages showing (logged and un-logged)
thank you for your help - <div style="margin-bottom: 0px; margin-left: auto; margin-right: auto; margin-top: 0px; overflow: visible;">
-
-
-
<div align="center">
-
<table border="0">
-
<tr>
-
<th>
-
<span class="small">
-
<?php if ($_SESSION["loggedInUser"] == $_SESSION["userCakeUser"]) { ?>Hi <strong><?php echo $_SESSION[$userdetails["Username"]]; ?>
-
-
!
-
-
<?php } else { ?><a href="login.php">Login</a>
-
<?php } ?>
-
</span> </th>
-
-
</tr>
-
<tr>
-
<td>
-
<span class="small">
-
<?php if ($_SESSION['loggedInUser'] == $_SESSION["userCakeUser"]) { ?><a href="logout.php">Logout</a>
-
-
<?php } else { ?>Register <a href="register.php" class="text_left">here </a>to download full mixes<?php } ?>
-
</span>
-
</td>
-
</tr>
-
</table>
-
</div>
-
-
<hr width=600px>
-
-
<a href="<?php echo $main_path; ?>index.php">Welcome</a><a href="
-
<?php echo $main_path; ?>Bio.php">Bio</a>
-
-
<!--logged-in-->
-
<?php if ($_SESSION['loggedInUser'] == $_SESSION["userCakeUser"]) { ?>
-
-
<a href="<?php echo $main_path; ?>Mixes.php">Mixes</a>
-
-
-
<a href="<?php echo $main_path; ?>Production.php">Production</a>
-
-
<?php } ?>
-
-
<!--not-logged-in-->
-
<?php if ($_SESSION['loggedInUser'] == NULL) { ?>
-
-
<a href="<?php echo $main_path; ?>mixes_unlogged.php">Mixes</a>
-
-
<a href="<?php echo $main_path; ?>production_unlogged.php">Production</a>
-
-
<?php } ?>
-
-
<a href="<?php echo $main_path; ?>Contact.php">Contact</a>
-
<a href="<?php echo $main_path; ?>links.php">Links</a>
-
<hr width=500px>
22 2866 Dormilich 8,658
Recognized Expert Moderator Expert
obviously $_SESSION[$userdetails["Username"]] does not exist or is empty. try var_dump($_SESS ION); to see what’s going on.
thx Dormilich. Sorry I'm really no expert in php, shall I put this instead of my query or after?
I've added it within the query and it brings NULL back. Does it mean username isn't what I should be using then?
Dormilich 8,658
Recognized Expert Moderator Expert
what query? it doesn’t matter where you put this, as long as it is executed.
if var_dump($_SESS ION); brings up NULL, there is something wrong with the session.
ok...what can I do to find out what's wrong with it?
Dormilich 8,658
Recognized Expert Moderator Expert
check out, where you set $_SESSION to NULL.
ok, I've checked this out and this is the "config.php " file, where the $_SESSION is set to NULL if not logged in and to $_SESSION["userCakeUs er"] if logged in (see code below)
Am I not using this properly? - <?php
-
include("settings.php");
-
-
//Dbal Support - Thanks phpBB ; )
-
include("classes/db/".$dbtype.".php");
-
-
//Construct a db instance
-
$db = new $sql_db();
-
if(!$db->sql_connect($db_host, $db_user, $db_pass, $db_name, $db_port, false, false)) die("Unable to connect to the database");
-
-
//Include classes
-
include("classes/class_newuser.php");
-
include("classes/class_newmail.php");
-
include("classes/class_loggedinuser.php");
-
-
//Include Functions
-
include("functions/user-funcs.php");
-
include("functions/general-funcs.php");
-
-
-
session_start();
-
-
//Global User Object Var
-
//loggedInUser can be used globally if constructed
-
if(isset($_SESSION["userCakeUser"]) && is_object($_SESSION["userCakeUser"])) $loggedInUser = $_SESSION["userCakeUser"]; else $loggedInUser = NULL;
-
?>
Dormilich 8,658
Recognized Expert Moderator Expert
where do you set userCakeUser?
userCakeUser is set in the mysql db table
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Tom |
last post by:
Hi
I have a web application using asp.net and c#. User has to login to the application with his username and pwd. However, I do not allow other user uses the same username and pwd to login, i.e. one set of login ID cannot be used for twice except the logged in user's session has expired or he exited the system and terminate the session (Session.Clear();).
Here is the C# code in my login cs file
= obj; //I created a session here after...
|
by: Siobhan |
last post by:
Hi
What is the recommended way to store a user's database credentials across
the pages of a web application so that each time the database is accessed the
system doesn't have to ask them for their username and password again
We have previously stored these in a session variable (encrypted) and
retrieved from their - but are worried about the impact on performance if the
number of users increases.
Had thought about cookies but worried...
|
by: Gleep |
last post by:
I've searched google intensely on this topic and it seems noone really knows how to approch this.
The goal I don't want clients to give out their usernames and passwords to friends, since the site
relies on subscrption fees.
Sessions ID's are matched between the browser and the server. So a users can login with same
username and password and those sessions are tracked individually.
Some suggest create table fields with the session ID...
|
by: BizWorld |
last post by:
Hi,
I have a scenario where i need to configure only Login.aspx page to use
SSL. All other application will run on HTTP protocol. If someone can
guide me how to accomplish this. One of my idea is to keep login.aspx
page in a seperate Virtual director and apply SSL only on that
directory but i dont know if it will have an impact on session (may be
it will create two sessions due to two different virtual directories).
If some one can...
|
by: John Meyer |
last post by:
index:
<%@ Page Language="VB" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
| |
by: simon |
last post by:
well i have admin panel and agent panel.
when i open admin panel and log in it works fine. but when agent opens
agent panel in different pc and login and acts something like open a
page or so, both admin panel and agent panel expires session and asks
for re-login. What would be possible reason for this? Please anyone can
help !!!
platform:
OS: windows 2000 server, IIS 6.0
Script : ASP, Javascript
|
by: Ben |
last post by:
Hello, I'll bet this has been asked a million times but I can't seem to find
a thread that gives the clear example I need.
This PC has MySQL and IIS configured and running. The MySQL database is
"myDB" with a table "myUsers" with fields "Username" and "Password". I also
have the MySQL ODBC driver loaded with a DSN "dsnMySQL" setup.
First question is can someone direct me to a site or provide a sample code
for a login page that...
|
by: =?Utf-8?B?S2VsbHk=?= |
last post by:
We just switched our web application from .NET 1.1 to 2. Once client can't
login out of several that have been successful. They enter a correct user
name and password, click the login button and they are redirected back to
login with no errors or login failure. The same login account works fine from
other machines at different locations.
This client had no problem logging in before we switched. The login
procedures are essentially the...
|
by: Josh |
last post by:
I run a Joomla website and am familiar with php in some but not all
aspects. Currently I am trying to find some solutions related to
session handling.
Am I correct in saying that "login" is kept in sessions? I can see
active sessions in my mysql database, but is that the only place this
information is stored? Sessions and cookies I know are related also,
but how specifically (session info stored in cookies?)?
Right now, when users...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |