4images Forum & Community

4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: Ironmagma on December 18, 2005, 09:38:56 PM

Title: Checking session from external program
Post by: Ironmagma on December 18, 2005, 09:38:56 PM
Hi all.  What all needs to be in a standalone PHP file to read the cookie for the session id and user ID, etc. and check to make sure all that information is correct and that the user is indeed logged in?

Basically I'm attempting to "steal" 4images's login system and use it as an additional site login system for special features for members.

I know I probably need to call the includes/functions.php file and maybe the sessions.php file(?) but then what?

Please help ASAP.

Thanks!  :)
Title: Re: Checking session from external program
Post by: V@no on December 18, 2005, 10:18:59 PM
I'm not sure if this will work, cause the cookies stored for your 4images directory only and wont be accesible from anywhere else...(I think)
Title: Re: Checking session from external program
Post by: Ironmagma on December 18, 2005, 10:23:33 PM
It's a program on the same domain, so it should work.  I can already access the cookies from other programs, I just need to know how to check the validity of the user's logged in state, and to get the user's username.
Title: Re: Checking session from external program
Post by: V@no on December 18, 2005, 10:28:55 PM
try this:
Code: [Select]
$nozip = 1;
define('GET_CACHES', 1);
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
if ($user_info['user_level'] > GUEST)
{
// user logged in.
}
else
{
// else user not logged in.
}
But I'm pretty much sure this will not work, especialy if a member has blocked cookies.
Title: Re: Checking session from external program
Post by: Ironmagma on December 19, 2005, 03:21:42 AM
Well, how does 4images check to make sure the user is logged in?
Title: Re: Checking session from external program
Post by: V@no on December 19, 2005, 04:45:06 AM
That's how it does...the session.php does the check. If it find sessionid in the cookies or in requested url, its looking it up in the database (v1.7) / php sessions (v1.7.1)
Title: Re: Checking session from external program
Post by: Ironmagma on December 19, 2005, 10:08:51 PM
So what function in sessions.php does the check, and what does it return? a boolean value?
Title: Re: Checking session from external program
Post by: V@no on December 20, 2005, 12:36:17 AM
its not function, its whole class. The class that almost entire sessions.php is made of.