![]() |
identify user in a different folder then the forum
Hi,
I have a another site which is not a part of the vbulletin forum but it's located in the parent directory. vbulletin forum => s-maof/Forum dir another site => s-maof/aaa dir I want to idintify users that are logged in the forum in the other site. I have included this code: PHP Code:
even though I am. Any help? |
Since it works using cookies, that will only work if you set "Path to Save Cookies" to "/" (should be one of the choices in the dropdown menu). That's in "Cookies and HTTP Header Options" section of the options. You might have to log out and back in again for it to take effect.
|
You need to actually activate a session. Are you seen in the session table at all?
|
Quote:
The domain that I am talking about is in : mydmoain.com/myFolder/app wheras my regular vbulletin forum users are in mydomain.com/Forum I want to detect my users in both urls! |
Quote:
It could cause a problem if you have more than one forum installed on your server, but if you do, I think you could fix that by using a unique cookie prefix for each one. |
Quote:
Entering an invalid setting can leave you unable to login to your forum so i'm a little hesitent about changing it (leaving my users unable to login and me unable to change it). isn't there another way. something like: PHP Code:
(I get an empty username and id..) |
I understand your concern, but I'm not sure what else to tell you. I think you either need to change the cookie path, or else your custom script needs to be under the /Forum directory. The issue has to do with when the user's browser decides to send the cookies, so you can't fix that by doing a chdir() in your script (because by the time your script is running, the cookies have either been sent with the request, or they weren't).
There is a file that comes with the vb distribution, in the "do not upload" folder, called tools.php. It allows you to fix certain things without neding to log in, by uploading that file to your admincp directory and then pointing your browser to admincp/tools.php (don't do it until you need it, because some other things won't work when the tools.php file is present). Anyway, one of the things it lets you do is reset the cookie path, so if you run in to a problem you should be able to fix it that way. |
hi kh99,
I have changed the setting to 'Path to Save Cookies' to '\' logged out and back in again. with the browser tried this sctipt again: PHP Code:
|
Hmm...well, at least it didn't break the forum. :) So are you seeing *any* info in $vbulletin->userinfo? (edit: I see now in your first post you say you are). You could try using something like Firefox with Firebug (the net tab) and see if the cookies are being sent (I still think it might be a cookie problem).
Also, maybe try include "./global.php" (with the ./ in front). Looking at your code I think you know php much better than I do, and I don't know why it should make any difference, but I seem to remember someone else having an issue before that was fixed by adding the ./ (Edit: but now that I see where you said you *are* getting some info in $vbulletin, it must be included correctly so probably that's not it). Edit: is the code you posted inside a function? That's another thing that doesn't work. |
no, it's empty,
I taught it was the xcache.var_size, so I changed it from 0M to 2M (restart apache) and tried again (no luck).. change it to ./global.php - also nothing. the $vbulletin->userinfo is empty. It was in a function -->I took it out from it and now the $vbulletin->userinfo is not empty but i get userid = 0 and username = not registered |
OK, well, it's getting closer. I think it's possible to do the include in a function, but you have to define some variables as global first. I know $vbulletin is one of them, but I can't remember what the others were. I know user Disasterpiece was trying to do that a while back and I think he finally succeeded.
Edit: here's the thread I was thinking of: www.vbulletin.org/forum/showthread.php?t=274455 . It looks like you also need $bootstrap as global. And it does look like maybe he wasn't completely successful (at least the last time he posted in that thread). |
I have change the global.php file like so :
PHP Code:
|
OK, sorry for the confusion - those comments were only about being able to include global.php from a function. And BTW, you could put the global statement in your code before it's included, that way you don't need to modify the vbulletin code.
But, if you put your include outside any function you should see the user info, so obviously you still have some other problem. One thing you might do is turn on errors in your custom script, if you haven't already. I think you can put error_reporting(E_ALL) and ini_set('display_errors', 1) at the beginning of your file. Sorry I'm not a lot of help, but this is a question that's asked periodically, and it's usually the cookie thing. |
1. tried global $bootstrap in the main php file.
2. tried error_reporting(E_ALL) and ini_set('display_errors', 1) - got errors but nothing to do with global.php 3. what do you mean by "and it's usually the cookie thing."? I have checked my browser cookies and I see the relevant cookies - bb_userid , etc... |
Quote:
You said you see the cookies - do you have a way to look at the request that's sent to your custom script to see if it includes the cookies? (Edit: or I suppose another way would be to have your custom script check to see if they're set). |
I see that the cookie bb_userid is set in my forum domain but if try to check in the other domain
PHP Code:
it's weird . aren't cookies suppose to be general for the whole browser? |
To be honest I don't know a lot about it. But my understanding is that cookies are only sent back to the domain/path that set them (so that you're not letting every site see all your cookies). I believe the script that sets the cookie can modify the cookie to allow it to be sent to other scripts. Here's a paragraph from the Wikipedia article on http cookies:
Quote:
that brings up another question - are your two sites on the same (top-level) domain? I believe leaving the "cookie domain" setting blank (which seems to be the default) will allow it to be sent to all related subdomains, but if you have an entirely different domain name for your other site, that might be the issue. |
Quote:
on is s-maof.com/GoldSig/app and the other s-maof.com/Forum I have set the cookie path to '/' (as you advised) which means the cookies are being sent to s-maof.com. from your logic - I should be able to see them from s-maof.com/GoldSig/app due to the face that it is a subdomain of s-maof.com. |
I did see in your first post where it looked like they were at the same domain, but thought I'd make sure. You're right, as far as I know the cookies should be sent with the settings you have.
Sorry, maybe someone else will have an idea. |
Hi kh99,
thank for all your help, I got it working with PHP Code:
It's weird sometimes it worked and sometimes it didn't. now it workes all the time. Thanks again :D --------------- Added [DATE]1347188933[/DATE] at [TIME]1347188933[/TIME] --------------- damm, it stopped working again for some reason... It works only on chrome kh99, what can be the cause? it worked fine, recognized me and another user, and now it stopped again.. |
Quote:
Hi kh99, It's still the same problem. It works on the localhost - perfectly but not on the remote host. Maybe I can extract those details from the browser cookies I can sees that I have PHP Code:
Any idea at all? |
All times are GMT. The time now is 04:58 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|