Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 27 Jun 2011, 22:36
codeit codeit is offline
 
Join Date: Jun 2011
$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:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Also, everytime I access this test.php page, it kicks out my login status on vbulletin.

Please help
Thanks
Reply With Quote
  #2  
Old 27 Jun 2011, 22:46
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Real name: Rob
Did you try $bbuserinfo['userid']?
Reply With Quote
  #3  
Old 27 Jun 2011, 22:50
codeit codeit is offline
 
Join Date: Jun 2011
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 27 Jun 2011, 23:00
borbole's Avatar
borbole borbole is offline
 
Join Date: Jan 2010
Can you post the whole code of your test.php page?
__________________
My mods.
Reply With Quote
  #5  
Old 27 Jun 2011, 23:02
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Same cookie domain + path?
Reply With Quote
  #6  
Old 27 Jun 2011, 23:07
codeit codeit is offline
 
Join Date: Jun 2011
Borbole: it's pretty much the whole code.. except the <?php tags.. here it is everything again (just a very simple code):


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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 27 Jun 2011, 23:10
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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 27 Jun 2011, 23:14
codeit codeit is offline
 
Join Date: Jun 2011
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 27 Jun 2011, 23:20
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Real name: Rob
Try changing this:

chdir($curdir.'/forums');

to this:

chdir($curdir'./forums');
Reply With Quote
  #10  
Old 27 Jun 2011, 23:26
codeit codeit is offline
 
Join Date: Jun 2011
Boofo:
that gives a syntax error

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

and
chdir($curdir.'./forums');
gives a "no such file or directory" error
Reply With Quote
  #11  
Old 27 Jun 2011, 23:36
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Real name: Rob
Look closer at my change. I didn't add the first dot.
Reply With Quote
  #12  
Old 27 Jun 2011, 23:42
codeit codeit is offline
 
Join Date: Jun 2011
Boofo:
I knew that.. the first part of my previous reply about the syntax error was for the exact change you gave, then I just tried a little more than what you suggested.. sorry didn't make it clear enough.

It's for sure a directory issue, I just tried to move test.php into the forums directory and removed the chdir stuffs and it works, so must be the chdir stuffs...
Reply With Quote
  #13  
Old 27 Jun 2011, 23:45
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
In the ACP under "Cookies and HTTP Header Options", what do you have "Path to Save Cookies" set to? According to the help for that option, unless you have it set to '/', the cookies won't work in other directories. (I guess that's what Adrian meant by "path").
Reply With Quote
  #14  
Old 27 Jun 2011, 23:57
codeit codeit is offline
 
Join Date: Jun 2011
YES! I just got it.. damn it
kh99: you're just right on, I actually just found out by comparing the settings on the two hosts, then got it to work.. then came back here and see your post exactly the same as what I found.

I recently moved my boards to vB so I'm still new to it, these little things will kill me more

Thank you all for your helps.
Reply With Quote
  #15  
Old 28 Jun 2011, 00:00
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Glad to hear you figured it out.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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


New To Site? Need Help?

All times are GMT. The time now is 19:23.

Layout Options | Width: Wide Color: