Topic: read user name on an unprotected page ? (Read 1906 times)
Atari ST fan
Posts: 8
68 credits Members referred : 0
« on: Aug 19, 2006, 07:20:42 pm »
Hello,
I use $_SESSION['user'] and also $user = $test_page_protect->user; to read the username. This is working as long as I do this in a protected site.
Now I want to read the user name on an unprotected page. I tried both but I was not successful. Actually I was not able to use the $test_page_protect->user function without getting Errors.
I was expecting: If the user is logged in, the username will be returned, if he is logged out, <blank> will be returned.
Can someone help me ? I just want to know which user is logged in when he is accessing an unprotected page.
Thank you, Philipp
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6691
34714 credits Members referred : 374
It's time to use PHP5!
« Reply #1 on: Aug 19, 2006, 07:37:17 pm »
Hello,
you can access
Code:
$_SESSION['user']
all the time until the user is logged out...
Atari ST fan
Posts: 8
68 credits Members referred : 0
« Reply #2 on: Aug 19, 2006, 08:40:59 pm »
Hello,
I just made a test: I logged in as a user, accessed a protected page and with $_SESSION['user'] I got the username. Perfect. But when I now access an unprotected page, $_SESSION['user'] returns <blank> even though the user is still logged on...
Philipp
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6691
34714 credits Members referred : 374
I just made a test: I logged in as a user, accessed a protected page and with $_SESSION['user'] I got the username. Perfect. But when I now access an unprotected page, $_SESSION['user'] returns <blank> even though the user is still logged on...
Philipp
do you tested this in a new window of internet explorer?
Atari ST fan
Posts: 8
68 credits Members referred : 0
« Reply #4 on: Aug 19, 2006, 10:08:17 pm »
no, in the same window. (p.s. I also tested it with Firefox and Netscape with the same result).
Philipp
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6691
34714 credits Members referred : 374
It's time to use PHP5!
« Reply #5 on: Aug 20, 2006, 09:01:23 am »
oooh I forgot, since your not using the class there is no session started
just inlude the class or place a session_start at the start of the page.
By the way you can access the methods of the class without protecting a page, its just a feature...
Atari ST fan
Posts: 8
68 credits Members referred : 0
« Reply #6 on: Aug 20, 2006, 12:03:09 pm »
Hi Olaf,
I just placed a session_start() at the beginning and it is working perfectly. Thank you very much for your quick answers !
Regards, Philipp
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6691
34714 credits Members referred : 374