Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-12-2005, 03:25 PM
t0ny t0ny is offline
 
Join Date: Nov 2005
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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 ?
Reply With Quote
  #2  
Old 07-17-2006, 11:08 AM
NeilFawcett NeilFawcett is offline
 
Join Date: Mar 2006
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #3  
Old 07-31-2006, 02:29 PM
sonata sonata is offline
 
Join Date: Jul 2005
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,

Have you two found any answer to the question. Please share with me if you have successfully done something with the sessionhash.
Reply With Quote
  #4  
Old 07-31-2006, 05:55 PM
NeilFawcett NeilFawcett is offline
 
Join Date: Mar 2006
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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...
Reply With Quote
  #5  
Old 08-01-2006, 12:35 AM
sonata sonata is offline
 
Join Date: Jul 2005
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 08-02-2006, 10:44 AM
NeilFawcett NeilFawcett is offline
 
Join Date: Mar 2006
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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") . "
	");
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:11 AM.


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.03858 seconds
  • Memory Usage 2,211KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete