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

Reply
 
Thread Tools Display Modes
  #1  
Old 06-27-2011, 08:36 PM
codeit codeit is offline
 
Join Date: Jun 2011
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default $vbulletin->userinfo['userid'] always returns 0

I'm trying to integrate a vb login form on my homepage but couldn't find no help so far.. even posted a question here last week but getting no answer. so I'm doing some experiments to find the way on my own...

For now, I'm having a test.php page which located at an upper directory of my forums, and include the forums' global.php file, just to be able to access the $vbulletin->userinfo data. However, $vbulletin->userinfo['userid'] always returns 0 as an Unregistered user even when I logged in.

I took the code to my local pc (running IIS) and it works just fine (of course I had to change the path due to Windows v.s Unix, but can't figure out why it doesn't work on my Unix host..

Here's a sort of my experiment code:

Code:
$curdir = getcwd();
chdir($curdir.'/forums');
require_once('./global.php');

//Use $bbuserinfo. 
echo('userid: ' . $vbulletin->userinfo['userid']);
echo('userid: ' . $vbulletin->userinfo['username']);
chdir($curdir);
Also, everytime I access this test.php page, it kicks out my login status on vbulletin.

Please help
Thanks
Reply With Quote
  #2  
Old 06-27-2011, 08:46 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you try $bbuserinfo['userid']?
Reply With Quote
  #3  
Old 06-27-2011, 08:50 PM
codeit codeit is offline
 
Join Date: Jun 2011
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yeah I did.. in fact, you can see my note there to use $bbuserinfo at first.. then I gave up with it and try $vbulletin ->userinfo...
$bbuserinfo['userid'] returns nothing, not even 0
Reply With Quote
  #4  
Old 06-27-2011, 09:00 PM
borbole's Avatar
borbole borbole is offline
 
Join Date: Jan 2010
Posts: 2,559
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can you post the whole code of your test.php page?
Reply With Quote
  #5  
Old 06-27-2011, 09:02 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Same cookie domain + path?
Reply With Quote
  #6  
Old 06-27-2011, 09:07 PM
codeit codeit is offline
 
Join Date: Jun 2011
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Borbole: it's pretty much the whole code.. except the <?php tags.. here it is everything again (just a very simple code):

Code:
<?php //test.php

$curdir = getcwd();
chdir($curdir.'/forums');
require_once('./global.php');

//Use $bbuserinfo. 
echo('userid: ' . $vbulletin->userinfo['userid']);
echo('userid: ' . $vbulletin->userinfo['username']);
chdir($curdir);

?>
Adrian:
Your comment kindda made me think.. but I believe it is, cuz this test.php is on the same host and everything, just on an upper dir of the forums, and I'm accessing both (the forums and the test.php) on the same browser...
Reply With Quote
  #7  
Old 06-27-2011, 09:10 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

FWIW I tried this on a linux host and it worked. Dumb question, but are you testing it with the same browser that you're logging in to vb with? (Sometimes I have IE and FF going at the same time).
Reply With Quote
  #8  
Old 06-27-2011, 09:14 PM
codeit codeit is offline
 
Join Date: Jun 2011
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, I basically have 2 tabs on my browser, one with vb, and the other with the test page.. login to the vb, then refresh the test page and it shows 0 for userid and Unregistered for username. Then go back to vb, it.. logged me out.

Also tried with IE since I have both IE and FF. same thing
Reply With Quote
  #9  
Old 06-27-2011, 09:20 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try changing this:

chdir($curdir.'/forums');

to this:

chdir($curdir'./forums');
Reply With Quote
  #10  
Old 06-27-2011, 09:26 PM
codeit codeit is offline
 
Join Date: Jun 2011
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Boofo:
that gives a syntax error
Code:
syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
and
chdir($curdir.'./forums');
gives a "no such file or directory" error
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 02:38 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.04011 seconds
  • Memory Usage 2,251KB
  • Queries Executed 11 (?)
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
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete