View Full Version : Custom PHP - Prevent vBulletin from timing users out?
WorldCraft
02-04-2013, 07:52 PM
Hello, I run a PHP-based Ajax chatroom (http://frug.github.com/AJAX-Chat/) on my forum that uses existing vBulletin logins for the chat. By design when users logout of the forums, they are automatically logged out from the chat as well. Unfortunately the auto-logout will occur to vB's timeout option (AdminCP -> Cookie Options -> Session Timeout).
The issue here is that many of my users will just want to chat and not browse the forums. They will be constantly logged out because vB "thinks" that they aren't being active. Is there any sort of PHP function or plugin I can set on the chat script so that they will not be timed-out?
Thanks,
Mike
I assume your chat script is including global.php? If you add a call to exec_shut_down() (sometime after you're done with the vb stuff), it should keep the users active.
WorldCraft
02-05-2013, 08:48 PM
For some reason it's causing errors to occur. I am placing the function call under my global.php call - require(AJAX_CHAT_PATH.'../global.php');
This is what I get when trying to access the chat when already logged in to the forums:
Query: SELECT userID, userName, userRole, channel, UNIX_TIMESTAMP(dateTime) AS timeStamp, ip FROM ajax_chat_online ORDER BY userName; Error-Report: Error-Code:
If I try to go to the chat and try to login directly, I get this database error:
Database error in vBulletin 4.2.0:
Invalid SQL:
SELECT
forumid,
title
FROM
forum
WHERE
options & 4
AND
password='';;
MySQL Error :
Error Number :
Request Date : Tuesday, February 5th 2013 @ 01:44:14 PM
Error Date : Tuesday, February 5th 2013 @ 01:44:14 PM
Script : http://www.x.com/forums/chat/
Referrer : http://www.x.com/forums/forum.php
IP Address : 72.226.103.183
Username : Unregistered
Classname : vB_Database_MySQLi
MySQL Version :
DivisionByZero
02-05-2013, 09:28 PM
an easy way to keep users active would be to write an easy script that calls global.php and refreshes every X minutes inside a 1x1 iframe in your chat page.
WorldCraft
02-06-2013, 02:21 AM
an easy way to keep users active would be to write an easy script that calls global.php and refreshes every X minutes inside a 1x1 iframe in your chat page.
Tried some Javascript functions that re-creates an iframe with the src pointed to globals.php at an interval. I still get timed out.
For some reason it's causing errors to occur. I am placing the function call under my global.php call - require(AJAX_CHAT_PATH.'../global.php');
I'm not sure why that's happening, but you would need to put the call to exec_shut_down() after anything that uses the vbulletin variables or functions. Maybe try moving it to the bottom.
WorldCraft
02-06-2013, 05:08 AM
Hmm. Well the chat uses multiple PHP files to run, so finding the end of the vBulletin functions may be out of the question here.
--------------- Added 1360186567 at 1360186567 ---------------
Refreshing global.php in an iframe doesn't keep users active (nor does refreshing global.php in its own browser tab). Anything else I could try?
miket1234
02-08-2013, 06:54 PM
I had the same problem and I solved it with installing a plugin called keep me log in. So basically, if you don't push the log out button from forum , the cookie never expire and you can chat until you close or the browser or you log out from forum.
Refreshing global.php in an iframe doesn't keep users active (nor does refreshing global.php in its own browser tab). Anything else I could try?
Maybe it will work if you use a script that includes global.php followed by a call to exec_shut_down().
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.