vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   The Session Table (https://vborg.vbsupport.ru/showthread.php?t=102800)

t0ny 12-12-2005 03:25 PM

The Session Table
 
Could someone please explain to me using the session table and the sessionhash cookie, how to check if someone is logged in?

Do I simply need to check if that particular sessionhash is in the table or do i need to mess with the lastactivity or anything ?

NeilFawcett 07-17-2006 11:08 AM

Quote:

Originally Posted by t0ny
Could someone please explain to me using the session table and the sessionhash cookie, how to check if someone is logged in?

Do I simply need to check if that particular sessionhash is in the table or do i need to mess with the lastactivity or anything ?

*bump*

I'm interested in the same thing...

I simply want to know say given a session ID, if the user is a valid logged on user.

Out of interest are old session records killed? ie: When a session hasn't been used for X amount of time I assume it's removed? What's the rules behind this?

ps: I'd also love to know if a user is also a member of a given group (ie: granting them additional features).

sonata 07-31-2006 02:29 PM

Hi,

Have you two found any answer to the question. Please share with me if you have successfully done something with the sessionhash.

NeilFawcett 07-31-2006 05:55 PM

In VBulletin there is a variable for the session id, and it's also held in a cookie. Given this you can then read the session file. This will tell you the user id and when the last activity was.

My issue of course is I want to validate in a another script (run directly from VBulletin) if the user is a valid user etc. I'll probably try something like this:-
a) Get the session id.
b) Read the session table for that id.
c) If the session is within 30 minutes old I'll assume we have a valid user. I may also check say the first two elements of the IP address as well, just to be super sure (also held on the session record I believe).
d) Given we have a valid user, I'll create my own session record in my application and cycle round that.

So the first time into my program where I don't have a session ID, I will validate the user has come from VBulletin by using the session ID, and pick up their user ID and username accordingly. Once done I'll create and use my own purpose written session file and live of that...

sonata 08-01-2006 12:35 AM

Quote:

Originally Posted by NeilFawcett
In VBulletin there is a variable for the session id, and it's also held in a cookie. Given this you can then read the session file. This will tell you the user id and when the last activity was.

My issue of course is I want to validate in a another script (run directly from VBulletin) if the user is a valid user etc. I'll probably try something like this:-
a) Get the session id.
b) Read the session table for that id.
c) If the session is within 30 minutes old I'll assume we have a valid user. I may also check say the first two elements of the IP address as well, just to be super sure (also held on the session record I believe).
d) Given we have a valid user, I'll create my own session record in my application and cycle round that.

So the first time into my program where I don't have a session ID, I will validate the user has come from VBulletin by using the session ID, and pick up their user ID and username accordingly. Once done I'll create and use my own purpose written session file and live of that...

Have you implemented your idea. Do you mind to sharing some of your codes like how to check lastactivity and the session time out? I don't know how lastactivity is computed and saved in vbulletin. Thanks in advance.

NeilFawcett 08-02-2006 10:44 AM

Quote:

Originally Posted by sonata
Have you implemented your idea. Do you mind to sharing some of your codes like how to check lastactivity and the session time out? I don't know how lastactivity is computed and saved in vbulletin. Thanks in advance.

Afraid not...

The variables of interest in the session table are:-
session.lastactivity
session.userid
Not sure what the session id field is called in the session file off the top of my head...

This following code returns all users currently online (ie: last activity > a cut off date)

Code:

        $datecut      = TIMENOW - *expiry age (eg: 300 secs?)*;
        $UsersOnline = $db->query("
                SELECT
                        user.username, (user.options) AS invisible, user.usergroupid,
                        session.userid,
                        IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid
                FROM " . TABLE_PREFIX . "session AS session
                LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)
                WHERE session.lastactivity > $datecut and user.userid > 0
                " . iif($vbulletin->options['displayloggedin'] == 1, "ORDER BY username ASC") . "
        ");



All times are GMT. The time now is 02:26 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01209 seconds
  • Memory Usage 1,732KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete