473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how do i check if user is logged on?

i would like to echo different links on each page depending on if the user is logged on or not,
e.g "log on" or "register" if they are not and "change style" if they are,
how do i do this?
cheers
Jul 10 '06 #1
2 9412
sashi
1,754 Expert 1GB
Hi there,

emm.. am sure every user allowed to login must have an access level assigned.. rite?? well.. then you can forward each user to a specific page based on their access level.. good luck my fren.. :)
Jul 10 '06 #2
ronverdonk
4,258 Expert 4TB
Assuming that you already know how to get the user to login, the following handles your problem.
[PHP]<?php
session_start();
/*--------------------------------------------------------------*
* Check if user is logged in. This check assumes that you have *
* saved the user's session data (in this case the 'username' *
* in the $_SESSION after a valid login. *
*--------------------------------------------------------------*/
if (!array_key_exists('username', $_SESSION)) {
// User is not logged-in, so display your 'please login' links
// ......................................
}
else {
// user is validly logged in, display whatever you want to
// ................................................
}
?>[/PHP]

Ronald :cool:
Jul 22 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: fr? | last post by:
Hi, i have a website , on wich users have to log in credentials are checked against mysql db some session vars are set during login for use somewhere else in the code. Is there a way to...
27
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate...
4
by: Brian Lowe | last post by:
I'm using Forms authentication with my user data in a SQL db. I have pages in the main appliaction folder accessible to anonymous users and I've set security to deny annonymous users access to...
9
by: Sameh Ahmed | last post by:
Hello there Is there a way through dotNet to check if a certain user is a member of a specific group? I use ADSI to get the memberships of the user then compare them to the group I want to check,...
4
by: Jarod_24 | last post by:
How do a windows-service detect whether a user is logged or not on a computer? So far i've found nothing in the windows api or any code examples that will allow me to figure this out. The...
5
by: Mitul | last post by:
Hi to all, I am working on a site in which I need to check whether user is online or not. If user successfully logged out then I can change status from online to offline but if user do not...
3
by: fomalhaut | last post by:
Hi All, I am building a tool for one of our company's service desks, and one of the functions I'm hoping to add is the ability to enter a username and find what PC that user is currently logged...
4
by: Simon Gare | last post by:
Hi all, below is an insert statement on an asp page that stores the date and time that a driver logged on, what I need is to check that they are now already logged on fields are SQL Server...
6
by: saddist | last post by:
Hello, For certain reasons I had to make my own USERS table where I store username, passwd, access_lvl and so on. Now I would like to display certian data from database depending on what...
2
by: Keith G Hicks | last post by:
asp.net 2.0 I have set my web.config as follows: <forms timeout="30"/(I know that's the default but I may chang it so the line's in there) I also have a few cookies I'm setting on my login...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
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,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.