vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Need help with sessions not being recorded on non-VB pages (3.5.1) (https://vborg.vbsupport.ru/showthread.php?t=101888)

vedman 11-29-2005 07:19 PM

Need help with sessions not being recorded on non-VB pages (3.5.1)
 
I kinda doubt that this issue is common, but I'm hoping someone out there will be able to offer some advice. My problem deals with sessions, and probably requires a solid familiarity with vbulletin 3.5.x code.

I have a website that is partially integrated with my forums. The forums are located at "/forums"; the main site and all of its pages are located at "/". I want users to be signed in all over the entire site, so I have this code in the header of all pages outside of the forums.

PHP Code:

chdir('forums/');
require_once(
'./global.php');
chdir('../'); 

I have a login box form which passes what it needs, including a redirect value which, after logging the user in, goes back to the page they were on, even outside of the forums. This (and the userid and primary groupid) are really all I make use of with the integration on my non-forum pages.

This has worked just fine for months, on vBulletin 3.5 RCx to 3.5 Gold. I upgraded to 3.5.1 over the weekend, and it still works perfectly .... except for one thing: sessions.

For some reason, now sessions are not being updated in the forums session table when a site visitor (guest OR member) visits a page outside of the forums.

Before the upgrade, the session table was updated whenever a visitor accessed any page with global.php included in it. For example, the session table locations would look something like:

/index.php
/forums/index.php
/forums/poll.php
/contests.php
/index.php
/forums/showthread.php?t=34983
/tourn.php
/contests.php
....etc

I upgrade from 3.5 Gold to 3.5.1, and now my sessions table looks something like:

/forums/index.php
/forums/poll.php
/forums/showthread.php?t=34983
/forums/index.php
/forums/poll.php
/forums/showthread.php?t=34983
...etc.

Pages located outside of the forums should be showing up in the session table... because they are being visited. But, no.

It appears that the session update is being bypassed, but after comparing the changes in class_core, init, global, functions, functions_online, and a couple of other vb pages, I can't figure it out. Out of the few changes that were made in those pages, nothing that would be dependant on the root path of the script has changed, that I saw.

I even backtracked the code from the UPDATE to `session` (I think that's in save(), in class_core.php). After spending hours comparing the updated forum pages to the previous version and making sure my options and plugins are all working, I'm close to giving up.

Can anyone offer any advice? Neither my cookie domain, nor path (nor any other HTTP/cookie settings) changed with the upgrade, but could it still be a cookie thing, or have something do with lastactivity in the cookie?

Much thanks ...

vedman 12-02-2005 06:32 AM

Nevermind, I found it, finally. Of course, it was a tiny little thing, and to be honest I don't know if it was added to 3.5.1 for security reasons... or... er... hope it's not super important.

init.php, line 202:

PHP Code:

    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))
    {
        
define('NOSHUTDOWNFUNC'true);
    }
    else
    {
        
vB_Shutdown::add('exec_shut_down');
    } 

The php version check at the beginning of the IF statement was added in 3.5.1. That was it ...I'm running PHP 4.

I removed PHP_VERSION < '5' OR , and sessions are once again being recognized (rather, it now gets as far as the database session handling). Sweet.

Dark Riku 12-03-2005 06:04 PM

So what did you put in your header for it to record sessions? Im interested also because i want to put conditionals but the page doesnt reconize the user isnt logged in, even tho its in the header.. so it doesnt work. Any help? thanks

vedman 12-03-2005 06:15 PM

This is the entirety of the VB integration, placed at the very top in the header of my non-forums pages (which are all located in the root folder of my site). This inclusion, along with the little 3.5.1 hack I mentioned above, will properly update the 'session' table whenever someone visits a page outside of the forums:

PHP Code:

//Require backend:
chdir('forums/');
require_once(
'./global.php');
chdir('../'); 

Then I use $vbulletin throughout the site, for the userid (if $vbulletin->userinfo['userid'] >= 1, visitor is a logged-in member), username, group id ... determining member/group restrictions, etc.

Oh and I don't define THIS_SCRIPT there, because I don't use any of vBulletin's templating or WOL... or anything else except the $vbulletin data. So.. your mileage may vary.

Dark Riku 12-03-2005 11:06 PM

Well im my site, im using this for a comment system. I put it above the form box and used else statement. But even if the user is logged in or not, it still shows the else.
I havethe header in an include. So its on a different page. Could this be why i am having this problem?

Tested out the code you sent me and it the same for logged in and logged out... Ill try puting the include in the news page also... although ive tried that before

vedman 12-04-2005 01:01 AM

Quote:

Originally Posted by Dark Riku
Well im my site, im using this for a comment system. I put it above the form box and used else statement. But even if the user is logged in or not, it still shows the else.
I havethe header in an include. So its on a different page. Could this be why i am having this problem?

Nah, having an included header wouldn't affect it. It sounds like you might have a cookie issue.

Here are a few things you could check. I am assuming your forum installation is located at http://www.yourdomain.com/forums, and you are running vBulletin 3.5.x).

1. Make sure in your vBulletin options, your cookie path is "/", and cookie domain is ".yourdomain.com" (notice the initial period -- this is crucial if you have any subdomains, but doesn't hurt otherwise).

2. Let's say your header is "header.php". It might look something like this:
PHP Code:

 
<?php
//Require backend:
chdir('forums/');
require_once(
'./global.php');
chdir('../');

$userid $vbulletin->userinfo['userid'];
$username $vbulletin->userinfo['username'];
?>

<html>
<head>
<title>blah</title>
</head>

<body>

3. Let's say your main page is "index.php". It might look like this:
PHP Code:

 
<?php
include "header.php";

if (
$userid 0){
      echo 
'Welcome, ' $username '!';
}else{
      
// display login form here
}

// assuming you have a footer include as well....
include "footer.php";
?>

Hope that helps. :)

Dark Riku 12-04-2005 07:20 PM

k cool, ill try that out

Nope... when i changed the cookie domain to my site, it woudltn let me log out on any page. My forum domain is /forum/ ... when I made the else say Not logged in and it says it again for logged in and out

If you have aim, my aim is balla1088 is you want to help.

Marco van Herwaarden 12-04-2005 07:48 PM

/forum/ is not a domain but a directoryname.

Dark Riku 12-04-2005 08:48 PM

I no that, im just stating that. I just used the suggested one, + that is what he told me to use. the .sitename.com

Dark Riku 12-06-2005 01:14 AM

To add to this, the condition in the header, for the login, work fine. I have if and else for guest and members...

EDIT: Well i narrowed this down to the only reason this is because of the script im using... im trying to find a way around this. I am using a news script, and its all one page, with alot of mysql calls, and i think the includes on this page is screwing up the forum login sessions... Any help?

Yay, found a way around, i had to call out information from the cookie stored by $_COOKIE['bbuserid'] then to get username i just called out the information by basic db connection instead of the include of it.


All times are GMT. The time now is 11:15 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.02735 seconds
  • Memory Usage 1,759KB
  • 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
  • (5)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete