Author Topic: Checking session from external program  (Read 4899 times)

0 Members and 1 Guest are viewing this topic.

Offline Ironmagma

  • Pre-Newbie
  • Posts: 4
    • View Profile
Checking session from external program
« 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!  :)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Checking session from external program
« Reply #1 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)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Ironmagma

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: Checking session from external program
« Reply #2 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.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Checking session from external program
« Reply #3 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.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Ironmagma

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: Checking session from external program
« Reply #4 on: December 19, 2005, 03:21:42 AM »
Well, how does 4images check to make sure the user is logged in?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Checking session from external program
« Reply #5 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)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Ironmagma

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: Checking session from external program
« Reply #6 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?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Checking session from external program
« Reply #7 on: December 20, 2005, 12:36:17 AM »
its not function, its whole class. The class that almost entire sessions.php is made of.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)