Welcome to Geeklog, Anonymous Thursday, November 28 2024 @ 12:08 am EST
Geeklog Forums
Find user id
Ofey
Anonymous
I'm really way out of my depth here in this forum.
But anyway, I'm trying to write a bit of php on a staic page and I wanted to know is there anyway to find out if a user is logged in or not.
Is there a global variable for the users ID. If it isn't set to null then I'd know user is logged in and registered.
Anyone have any ideas?
Regards,
But anyway, I'm trying to write a bit of php on a staic page and I wanted to know is there anyway to find out if a user is logged in or not.
Is there a global variable for the users ID. If it isn't set to null then I'd know user is logged in and registered.
Anyone have any ideas?
Regards,
9
10
Quote
Status: Banned
machinari
Forum User
Full Member
Registered: 03/22/04
Posts: 1512
you may need to declare this global depending upon your script...
$_USER['uid'] will be '1' for anonymous, '2' for root, above 2 for logged in members.
I think I have that right.
Hope that helps
$_USER['uid'] will be '1' for anonymous, '2' for root, above 2 for logged in members.
I think I have that right.
Hope that helps
13
8
Quote
Status: offline
ofey
Forum User
Full Member
Registered: 03/18/05
Posts: 213
Location:Dublin, Ireland
Tried:
global $_USER['uid'];
$test =$_USER['uid'];
echo $test;
Obviously this is not how to declare global variables.
So how is it done?
(There is absolutely nothing else on the page.
I just want to get the user ID into a variable.)
Regards,
Those who say it can't be done, are usually interrupted by others doing it.
global $_USER['uid'];
$test =$_USER['uid'];
echo $test;
Obviously this is not how to declare global variables.
So how is it done?
(There is absolutely nothing else on the page.
I just want to get the user ID into a variable.)
Regards,
Those who say it can't be done, are usually interrupted by others doing it.
8
28
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
May I suggest reading a book or online resource about PHP?
global $_USER;
echo $_USER['uid'];
bye, Dirk
global $_USER;
echo $_USER['uid'];
bye, Dirk
12
8
Quote
mach
Anonymous
my apologies, I should have been more specific.
10
12
Quote
Status: offline
ofey
Forum User
Full Member
Registered: 03/18/05
Posts: 213
Location:Dublin, Ireland
Aren't global variables not defined elsewhere is geeklog. Like when someone logs in. And all I want to do is use that variable. For example just to simply echo it.
Why is it not as simple as this?
Those who say it can't be done, are usually interrupted by others doing it.
Why is it not as simple as this?
Those who say it can't be done, are usually interrupted by others doing it.
12
8
Quote
Status: offline
ofey
Forum User
Full Member
Registered: 03/18/05
Posts: 213
Location:Dublin, Ireland
Of course global variables are defined elsewhere, but obviously must be declared wherever I want to use them.
Regards
Those who say it can't be done, are usually interrupted by others doing it.
Regards
Those who say it can't be done, are usually interrupted by others doing it.
13
7
Quote
Status: offline
ofey
Forum User
Full Member
Registered: 03/18/05
Posts: 213
Location:Dublin, Ireland
Found exactly what I was looking for at:
here
For anyone interested, this works for me:
global $_CONF, $_USER;
print ("username={$_USER['username']}
");
print ("userid={$_USER['uid']}
");
print("remote address= {$_SERVER['REMOTE_ADDR']}
");
print("http remote address {$HTTP_SERVER_VARS['REMOTE_ADDR']}
");
print("site url= {$_CONF['site_url']}
");
Those who say it can't be done, are usually interrupted by others doing it.
23
6
Quote
All times are EST. The time is now 12:08 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content