...

View Full Version : vBulletin Sessions



Andy92
01-08-2008, 12:06 AM
Hi guys,

I would like to know how and where i can change/edit the vbulletin sessions.

What script sets them?

Also i would like to know what the session's name is.

Thanks in advance.

Fou-Lu
01-08-2008, 12:43 AM
Depends on your version of vB.
Assuming your running on 3.x, I recall its under includes/sessions.php
If the version is 2.x, I believe its under .global.php.
Hope that helps.
Oh, and for the name, its either sessionid or s, depending on the version/configuration. I recall that 3.x maps s to sessionid. Hope that helps.

Andy92
01-08-2008, 05:00 PM
Yes, i am using the lates version 3.7

Basically, is there any way so that i an display the username etc when people are logged into my forum accross other parts of my website?

Fou-Lu
01-08-2008, 06:18 PM
Been awhile since I've manipulated the vB files, but if you are using a session that is defined by the vb sessions, the database should have a record of the location. I'm not 100% certain where to find it (probably the online script), but there should be information relating to the location of the user and mapping it to a specific phrase for their location (eg, location: index.php ==> map it to 'Home Page' for example). Take a look, I'll check when I get home on my files (they are older than yours though)

Brandoe85
01-08-2008, 08:02 PM
You'll have to do some digging but I did this a bit ago and believe when they log into the forum you can check a cookie called $_COOKIE['bbsessionhash']. From there it joins to a session table and then back to the user table.

Do some testing by loging in and doing some print_r's and checking the output.

Good luck;

Andy92
01-08-2008, 10:28 PM
Ok got it.

But, i have a few more questions about vbulletin.

1) I have been searching around for ages. Is there a way to display the number of users / guests online on a page that is another part of my site?

Thanks!

Fou-Lu
01-09-2008, 01:26 AM
You'll have to do some digging but I did this a bit ago and believe when they log into the forum you can check a cookie called $_COOKIE['bbsessionhash']. From there it joins to a session table and then back to the user table.

Do some testing by loging in and doing some print_r's and checking the output.

Good luck;

That does sound right Brandoe, but I don't recommend following this option - not everone may use cookies (even session only cookies). I would opt for the method of including the initialization script from the VB into all the site scripts, that will allow auto generation of sessions for you - super handy as well (though kinda cheap method ;))
As for getting the number, you can run a query to select from the session table, something like:
SELECT count(*) AS Guests,
(SELECT count(*) AS Member FROM Session WHERE userID > 0) AS Members
FROM Session WHERE userID = 0;
That will resultset with a Guest count and a Member count.

Andy92
01-09-2008, 04:15 PM
I have done that, but it displays wrong. I mean it displays right at first, then vbulletin starts to not display inactive guests, so say if there were 15 guests online, and after 15 mins there were only 10 guests left, vbulletin would display this, but the other 6 guests that are not online anymore, their mysql records are still in the table for another 10 minutes or so, so i cant get it to display right at all.

Andy92
01-09-2008, 10:52 PM
Anyone know?

nirvana43
12-19-2010, 02:03 PM
There is 1 very easy way to do this,
Just use following syntax to fetch any information about currently logged in user :
To fetch username of currently logged in user : vbulletin->userinfo['username'];
Currently logged in user's email address : vbulletin->userinfo['email']
Userid of currently logged in user : vbulletin->userinfo['userid']

To give more detailed info on this,
1. just login to your PhpMyAdmin
2. Expand your vBulletin database and see the structure of "user" table.
NOTE : if you are having database prefix then look for your_prefix.user table.
3. In structure whatever field names you see there, if you put that field name in vbulletin->userinfo['fieldname'] it will give you desired data of currently logged in user.

I hope this info helps you.

Regards
Aditya Hajare



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum