If User is Logged In/Out

Posted by jyaron 
If User is Logged In/Out
July 17, 2008 01:08AM
I'm trying very hard to figure this out, but I just can't seem to wrap my head around the code behind Phorum. I understand the basic concepts of sessions and other simple login scripts, and I've searched hard through the files of Phorum, but I can't seem to find a solution to this particular problem.

What I need is a way to say "this person is a user and is logged in, so display this code." If not it would say "this person is not identified as a user nor is he/she logged in, so display this code." This code would be placed in a .php file that is outside of the Phorum directory (where phorum would be found in /forum/ and the other files would, essentially, be in ../ ).

If anybody could give me some hints as to how I would do this it would be greatly appreciated.

[www.expressthemusic.com] - Going Live Soon.
Re: If User is Logged In/Out
July 17, 2008 01:12AM
Sounds like you are looking for the quick authentication code, which you can use to determine outside Phorum if a user is logged in or not. See the quick authentication thread.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: If User is Logged In/Out
July 17, 2008 01:17AM
I literally just found that thread, tried it out, and found it to work. Awesome.

You guys are great, thanks :) :)
Re: If User is Logged In/Out
July 17, 2008 01:26AM
Oh, one more question:

Is there a way to just simply destroy the login session (basically, to logout)? The same way the aforementioned solution was a simple way to see if logged in or out, I just want to simply logout and be done with it.

So, is there an easy way to do it?
Re: If User is Logged In/Out
July 17, 2008 01:29AM
Sure, simply destroy the cookie that was set by Phorum.
That is enough to log a user out.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: If User is Logged In/Out
July 17, 2008 01:32AM
What is the name of the cookie? (Sorry, I'm not sure if I entirely understand cookies... sessions I know alright, but cookies I haven't really touched).
Re: If User is Logged In/Out
July 17, 2008 01:45AM
If you take a look at the quick authentication script, then the hint for what cookie to use is at the very first line of the code:
if(isset($_COOKIE["phorum_session_v5"])){

So Phorum's login cookie is called "phorum_session_v5".
Destroy that cookie and you're logged out automatically.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: If User is Logged In/Out
July 17, 2008 01:47AM
Quote
jyaron
What is the name of the cookie? (Sorry, I'm not sure if I entirely understand cookies... sessions I know alright, but cookies I haven't really touched).

Wow, just.... wow. That is like saying, I understand a car, but steering wheels, I have not used them much. Sessions are nothing more than a figment of your imagination that is held together by a file, row in a database or some memory cache and a cookie that tells the server which file, row in a database or memory location to grab when the user comes back. You have to understand cookies to understand sessions. You just can't understand one without the other.

Now, perhaps you meant to say "I have used the poor excuse for session management that is the PHP built in session code and I know how to set a value in $_SESSION and have it magically appear in another request. I don't understand how it appears, but I just know that it does and I am happy with that level of understanding."

Sorry, cookies and sessions is a rant of mine. Its not you, its me.

Brian - Personal Blog
Re: If User is Logged In/Out
July 17, 2008 01:56AM
Quote
Brian Moon
Quote
jyaron
What is the name of the cookie? (Sorry, I'm not sure if I entirely understand cookies... sessions I know alright, but cookies I haven't really touched).

Wow, just.... wow. That is like saying, I understand a car, but steering wheels, I have not used them much. Sessions are nothing more than a figment of your imagination that is held together by a file, row in a database or some memory cache and a cookie that tells the server which file, row in a database or memory location to grab when the user comes back. You have to understand cookies to understand sessions. You just can't understand one without the other.

Now, perhaps you meant to say "I have used the poor excuse for session management that is the PHP built in session code and I know how to set a value in $_SESSION and have it magically appear in another request. I don't understand how it appears, but I just know that it does and I am happy with that level of understanding."

Sorry, cookies and sessions is a rant of mine. Its not you, its me.

Haha, that's basically exactly what I meant. I'm truly a novice when it comes to php/mysql coding, but I'm getting there. However, XHTML/CSS is where I can help others out if necessary :P Thanks for sobering my idea of understanding when it comes to sessions and cookies, hahaha... I'm still getting a kick out of your 2nd paragraph. Awesome.
Re: If User is Logged In/Out
July 18, 2008 10:41PM
One more question: Is there a way, with this quick authentication method, to see if the user is an admin?
Sorry, only registered users may post in this forum.

Click here to login