View Full Version : Different cookie for AdminCP
sv1cec
04-04-2009, 10:26 AM
Some years ago, when I first started using vB, I got frustrated from the fact that every time I logged out from the forums, I also got logged out from adminCP and vice versa. So I requested some help for that and another old timer, Nexialys, was good enough to come up with a two-lines code that you added in your init.php and did that. It created a different cookie prefix for AdminCP, so all was well.
Nexialys approach was very elegant and simple. It added a different cookie prefix, if you were in AdminCP than if you were in the Forums.
Unfortunately, being an old dog, I didn't follow up the development of vB, I had a hard time getting in grips with the coding scheme they developped after release 3.5. But now, I had just created a new site and I need that same functionality. I know I can use a different browser to avoid the problem, but I do not want to do that. All I want is to have separate cookies for AdminCP and for the Forums, so that when I log out of the one, it doesn't also log me out of the other. The current init.php is totally different than the old one used in vB 3.0 that I can work on. So.....
Can someone help me with this? Can someone come up with a way to have a different cookie prefix for admincp than for the forums?
Needless to say, your help will be greatly appreciated.
Dismounted
04-05-2009, 05:05 AM
See functions_login.php, process_new_login().
sv1cec
04-05-2009, 07:15 AM
Ah, thank you very much Sir, sincerely appreciated. Time to study 3.8 code a little, but I think I can patch that function to work like my old one.
May I come back to you, if I face the wall?? :)
Rgds and again, many thanks!
nexialys
04-05-2009, 10:25 AM
ARGH, an old dog...
yeah, the function changed, to avoid my hack to work.. lol
i never touched it again, but i suppose it would be simple to modify the code by hand -- as there is no hook there!...
sv1cec
04-05-2009, 11:06 AM
Hey buddy, how are you? Long time no talk. How are you doing?
Now that I know where to look, I am sure I'll figure out how to patch the code. Who care for hooks? LoRL, I am still at 3.0.xx in my first site, managed to learn that quite good, I doubt if there is a single file on that site which doesn't contain one patch or another. But going to the latest versions, well, it's tough to teach an old dog new tricks.
Glad to see you around.
Au revoir mon ami! A bientot!
P.S. That old mod you made for me, doesn't even exist in this site, it was deleted (like others for 3.0.xx I guess) some time ago. Why people think that 3.0.xx is obsolete??
Ahhh Victory!!!!!
After some looking around, I managed it.
The patch has to be made in class_core, function fetch_config.
If anyone is interested, please let me know, I'll make it available.
PaintballHQ
04-05-2009, 07:02 PM
Ahhh Victory!!!!!
After some looking around, I managed it.
The patch has to be made in class_core, function fetch_config.
If anyone is interested, please let me know, I'll make it available.
I am interested in this :up:
sv1cec
04-05-2009, 08:12 PM
OK, let me get the original file so that I can have both the before and after the change code and I'll post it here some time tomorrow.
PaintballHQ
04-05-2009, 08:31 PM
OK, let me get the original file so that I can have both the before and after the change code and I'll post it here some time tomorrow.
Thanks, appreciate it.
Dismounted
04-06-2009, 04:19 AM
My guess: Find:
define('COOKIE_PREFIX', (empty($this->config['Misc']['cookieprefix']) ? 'bb' : $this->config['Misc']['cookieprefix']));
Replace With:
define('COOKIE_PREFIX', (VB_AREA == 'AdminCP' ? 'cpprefix' : $this->config['Misc']['cookieprefix']));
sv1cec
04-06-2009, 07:00 AM
As I said, my coding experience stops at vB 3.0.xx, so don't count me as the best alternative for advise, but here is what I did, based on Nexialys original hack, for 3.0. Don't ask me what the first conditional does, I have no idea, that's how Nexialys did it, that's how I did it.
Edit class_chore.php and find:
define('COOKIE_PREFIX', (empty($this->config['Misc']['cookieprefix']) ? 'bb' : $this->config['Misc']['cookieprefix']));
Replace that with:
$admincpdir = $this->config['Misc']['admincpdir'];
if (preg_match("/$admincpdir/i", $_SERVER['HTTP_REFERER']) OR (VB_AREA =='AdminCP'))
{
$cookieprefix = 'acp_'.$this->config['Misc']['cookieprefix'];
}
else
{
$cookieprefix = $this->config['Misc']['cookieprefix'];
}
define('COOKIE_PREFIX', (empty($cookieprefix)) ? 'bb' : $cookieprefix);
You can substitute 'acp_' with any prefix you want the admincp cookie to have.
Save the file and upload it to your server.
On a side note, I find it particularly frustrating (and it reminded me why I never upgraded to vB 3.5 etc) that the new coding scheme used by vB is so crazy. In some places, they use $vbulletin->config in other places they use $this->config. In some places, they use $this->config["$_SERVER[HTTP_REFERER]"], in other places they use $_SERVER['HTTP_REFERER'] and in others they user REFERRER. In some places, the $admincpdir works, while in others it doesn't. I really do not understand why it is so difficult to have a consistent coding scheme all over the place.
Oblivion Knight
06-20-2009, 10:24 PM
Just today I remembered about this useful modification for 3.0.x, and wondered if it had been done for 3.8.x..
Used the above code, and it's just as sweet as I remember! Thanks sv1cec. :)
sv1cec
06-21-2009, 05:43 AM
Most welcome, Sir. Glad if I can help every now and then.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.