View Full Version : How do you update cookie/session?
nicedreams
02-22-2006, 09:23 PM
How do you update the cookie/session in vb3.5.4 from a non vb page?
Is there a function in vb I can call to update it?
I do not want my users to be logged out of vb when they are browsing other parts of the site outside of vb. I do not want to increase the cookie timeout, nor do I want to use the remember me box. So I want to be able to access the vb cookie/session info and update it so the user isn't timed out if they are in a separate part of the site over the cookie timeout.
Jim
Marco van Herwaarden
02-22-2006, 10:34 PM
Just include global.php on your page, all will be handled automatic.
nicedreams
02-22-2006, 11:17 PM
Just include global.php on your page, all will be handled automatic.
That does not work. I called global.php with
chdir('forums');
require_once('global.php');
The page loads correctly, so it was able to load and access global. I printed the vbulletin array and it was there.
But just including this file does not update anything with the cookie or session.
I went from the forum home to my page, waited for the cookie to timeout, reloaded my page a few times, then went to the forum home and I was no longer logged in.
Jim
Ok, so I tried to use the vbsetcookie function. I'm not sure how it works, or can find any info about it. But with this entered: vbsetcookie('sessionhash', $sessionhash,0);
It updates the lastactivity and location field in the session table, but it displays an error message of "Unable to add cookies, header already sent."
What does that error message mean? Am I not calling the vbsetcookie function correctly?
Jim
Marco van Herwaarden
02-23-2006, 08:31 AM
To test if it is working, you should do the following:
- Login to your board
- Switch to your page. Keep refreshing the page once in a while, and keep doing this until the cookietimeout has passed.
- Now go back to your board.
PS Is your page and the board on the same domain?
nicedreams
02-23-2006, 12:50 PM
To test if it is working, you should do the following:
- Login to your board
- Switch to your page. Keep refreshing the page once in a while, and keep doing this until the cookietimeout has passed.
- Now go back to your board.
PS Is your page and the board on the same domain?
I said I did that. I made sure I refreshed my page enough so if the cookie was working there, it wouldn't time out. But when I go back to the forums, it had. They are on the same domain. The page is in the root dir above forums.
Does global.php call vbsetcookie when it is included? If it does, how can I check for error messages that are not shown?
Jim
hidjra
03-07-2006, 09:06 PM
I said I did that. I made sure I refreshed my page enough so if the cookie was working there, it wouldn't time out. But when I go back to the forums, it had. They are on the same domain. The page is in the root dir above forums.
Does global.php call vbsetcookie when it is included? If it does, how can I check for error messages that are not shown?
Jim
There's some changes in init.php regarding the NOSHUTDOWNFUNC. Take a look in init.php. Look for this around line 202.
if (PHP_VERSION < '5' OR ((SAPI_NAME == 'cgi' OR SAPI_NAME == 'cgi-fcgi') AND $vbulletin->options['gzipoutput'] AND strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false))
If your on php 4 you need to make some changes to the if statement above, change "PHP_VERSION < '5'" to "PHP_VERSION < '4'" or so. To test things out you can check out the sessions table, look for your own sessions and see if the lastactivity changes when browsing nonvb-pages.
I've had similair problems when trying to include vbuserinfo on nonvb pages. Now everything works fine, but i'm not satisfied. I'm trying to figure out how to include vbuserinfo, update sessions and cookies without including global.php. There is to much complexity in the vb environment and i want to eliminate any overhead by not including/using any more than strictly necessary :disappointed:
Goodluck,
Hidjra
asmith
06-12-2012, 02:59 PM
I realise I'm digging up a very old thread here but I have this exact problem.
I run my forum (3.8.1) and use the vbulletin authentication for my site.
The majority of the site usage would be pages that are not part of the forum but are authenticated by vbulletin.
My forum is on a domain like this w ww.mydomain.com/forum and my other pages are on a subdomain like this pages.mydomain.com.
I have my session timeout set to 3600 at the moment because browsing through the non-forum pages of my site does not update the session tables.
I have path to save cookies set to /
I have cookie domain set to .mydomain.com
On all my site pages I chdir to forum directory and include global.php but still my sessions table doesn't get updated.
I have taken the extreme measure of including a hidden iframe that loads the forum index inside just to keep the session updated ! :eek:
I'd appreciate any advice on this please.
Thanks.
the session is updated in the shutdown code, which in vb is usually called at the end when the output is generated, so just including global.php isn't enough. I believe if you add a call to exec_shut_down() that should take care of it.
asmith
06-12-2012, 03:34 PM
the session is updated in the shutdown code, which in vb is usually called at the end when the output is generated, so just including global.php isn't enough. I believe if you add a call to exec_shut_down() that should take care of it.
Excellent !
That did the trick. I've searched these forums and seen many posts regarding this and never found anyone give the solution !
Thanks.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.