The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Generating session externally (bbsessionhash cookie and session table)
Solution now found, check a few posts below...
Ok here is my current project: I am attempting to have users on my website (www.mysite.com) login and have them also logged in on my forum (forum.mysite.com). They can share cookies as they share the domain, right? When using my login function on my website, I create the bbuserid and bbpassword cookies appropriately. This is fairly simple. Creating the session does not appear to be. As anyone using external login knows, a row in the session table must be created that has a matching sessionhash to that found in the bbsessionhash cookie. Im trying to figure out how vbulletin creates the session hash. Ive been able to create the idhash, as well as am able to fill out the userid, host, lastactivity, and useragent fields. I am guessing, since this is external login, that the location field would be set to '/'. The function fetch_sessionhash looks like such a maze... it looks liek an md5 of Time(), $_SERVER['REQUEST_URI'], idhash, user ip, and a random # from 1 to 1000000. If, in my websites controller, I send a row to the session table containing the info above, along with my bbuserid and bbpassword cookies, will vBulletin think I am logged in? Will it work if I generate the sessionhash that way from my website and then navigate to my forum? If not, how do you create the proper row in the session table in order to be "logged in" on vBulletin? I have been searching the forums all day for the answer to this, and am unable to find any useable info. Could anyone show me the minimum data to send to the vb_session table in order for external login to work? TIA :up: --------------- Added at 21:50 --------------- Oh and another question... will it work if I just place some random string in the sessionhash and also match that string in the bbsessionhash cookie? Will it find me logged in and just switch these strings once ive navigated to the forum or at least somewhere within the forum? |
#2
|
||||
|
||||
Why don't you do this.
1. Copy the login form HTML from the navbar template. 2. Replace all the variables ($vbphrase etc), with plain text 3. Add the absolute url to /clientscript/vbulletin_md5.js to make sure it gets included. 4. Add the absolute url to the form's action 'login.php?do=login' You're done, it'll log you in and redirect you back to where you were. |
#3
|
|||
|
|||
lol... that sounds way too easy. ill give it a shot...
still, can anyone answer the original question? |
#4
|
||||
|
||||
You've already found the formula...fetch_session_hash(). Simply trace back the constants.
TIMENOW PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
|
#5
|
|||
|
|||
well because of the random func on the end, is this even possible? Will a new session be generated once I navigated to the forum regardless of what I insert into the table and set the cookie to?
It appears that after creating the above data, that navigating to the forum creates a new session for a non-logged in user, and overwrites the cookie for the logged in user (or rather, user attempting to log in externally). Therefore, am I safe in assuming that this isnt possible? --------------- Added at 16:20 --------------- Quote:
PHP Code:
has anyone here gotten external login to work properly? |
#6
|
|||
|
|||
i was able to do this by using the php headers function, if anyone is interested in doing this in the future.
you may need to visit www.php.net and research cURL() and the header() funcs to get this to work right first, my website opens a curl session and emulates the same action as the login form (sends the info through a post array). then, i save the results of the curl session in a string (the results will be the html page that the login routine on VB will return). I then parse the string where the cookies are found - this would be the sessionhash cookie and the other cookies generated by the login routine. i create the userid and such cookies with my own funcs that act just like the login on vb. then i take the string with the session hash in it and store it in a variable to be sent with the header(). sending all 5 headers as setcookie headers properly creates the sessionhash, userid, and other cookies (NOTE: this is *NOT* the setcookie() func, as that will not work from one domain to another). i can now login externally from my website to the forum. |
#7
|
||||
|
||||
Quote:
Sorry, I didn't realize you had replied here. Here's the code I threw together a month ago. Works fine. Just edit the first two lines, and test it out. PHP Code:
|
#8
|
|||
|
|||
ianskate, it sounds like you have a good solution. I'm pretty competent with curl, but since I'm in the same EXACT situation as you (forum is on a subdomain, on the same server), would you mind sharing your code? :erm: That would save me at least a couple of hours coding and debugging.
Thanks in advance! -Matt |
#9
|
||||
|
||||
This is amazing, I've been wondering how to make users logged from bbpixel's joomla bridge appear in useronline... but it doesn't seem easy at all.
I get it you need to build a sessionhash yourself and put it in the sessiontable? what happens if you just insert a row in vbsession with userid and location? |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|