Not logged in. · Lost password · Register
Forum: Support Bug reports and troubleshooting RSS
Cookie-trouble
Running several UNB forums in one browser
Reply
Avatar
Reply · Quote rvwsak #1
Member since Jul 2005 · 107 posts · Location: Norway
Group memberships: Members
Show profile · Link to this post
Subject: Cookie-trouble
I have just updated my two forums to 1.6.4 from 1.5.3 and 1.6.3 respectively. The addresses are:

http://www.buf.no/forum/ (native language forum) [tab1]
http://www.buf.no/unb/ (English language forum) [tab2]

In Firefox I view each forum in separate tabs, [tab1] and [tab2]. Also, on both forums I have an admin-user called "oyvind" (maybe this is what causes the hiccup). Now, suppose I log in to [tab1] with user "oyvind". All is fine. I log in to [tab2] with user "oyvind". Still all is fine. But when I return to [tab1] and click "Forum", then the user "oyvind" suddenly shifts to another user! Exactly the same thing occurs if I go back to [tab2] and click "Forum": the system automatically switches to another user in that forum! I tried to delete the relevant cookies in Firefox and to deactivate cookies in the UNB settings. No luck. What fixed it was to ban all cookies from this site in Firefox. But this is not a very elegant solution. Do I simply have to change the name of one of the admin users? Or is there a way to deal with this?

I should mention that both forums use the same database only with different prefixes.
Dixi et liberavi
Avatar
Reply · Quote rvwsak #2
Member since Jul 2005 · 107 posts · Location: Norway
Group memberships: Members
Show profile · Link to this post
I guess I just escaped the problem for the time being by logging in as two different users in the two forums. If anyone has an explanation or real solution, I'm all ears.

In the meanwhile I have another question:

The post view counter does not seem to work on new posts, i.e. posts created after this update. All the old post have their view counts intact, but the new posts have no view counts at all. Not yet anyway. The increment on the old posts works OK.
Dixi et liberavi
Avatar
Reply · Quote rvwsak #3
Member since Jul 2005 · 107 posts · Location: Norway
Group memberships: Members
Show profile · Link to this post
After some more testing it seems it does count the new posts too (posts made after the software update). However, it only counts views made by users, not by guests. Is this a new feature or is there something wrong with my installation?
Dixi et liberavi
Avatar
Reply · Quote Yves (Administrator) #4
User title: UNB developer & webmaster
Member since Jan 2004 · 3740 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #1
This is a known problem. By default, UNB uses / as the cookie path. So both UNB instances share their cookies. So they also share sessions. And since the logged in user is only determined by its user ID, you can only have a single user ID in both instances. The solution is to specify correct cookie paths in both instances. I see now that this has not been prepared in UNB1 yet. Here's some code from UNB2 that should solve the problem:

  1. // Use the URL path of the calling script as cookie path.
  2. $cookiePath = dirname($_SERVER['PHP_SELF']) . '/';
  3. ini_set('session.cookie_path', $cookiePath);

You can just insert these lines at a very early place in the UNB source code, like at the beginning of forum.php.

Be sure to clear out all cookies from the domain in your browser. They will be in the way when testing the new code.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
Avatar
Reply · Quote Yves (Administrator) #5
User title: UNB developer & webmaster
Member since Jan 2004 · 3740 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #2
Please consider opening a new thread for a different topic.

I have no idea what this could come from, with your description.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
Avatar
Reply · Quote rvwsak #6
Member since Jul 2005 · 107 posts · Location: Norway
Group memberships: Members
Show profile · Link to this post
In reply to post #4
Quote by Yves:
This is a known problem. By default, UNB uses / as the cookie path. So both UNB instances share their cookies. So they also share sessions. And since the logged in user is only determined by its user ID, you can only have a single user ID in both instances. The solution is to specify correct cookie paths in both instances. I see now that this has not been prepared in UNB1 yet. Here's some code from UNB2 that should solve the problem:

  1. // Use the URL path of the calling script as cookie path.
  2. $cookiePath = dirname($_SERVER['PHP_SELF']) . '/';
  3. ini_set('session.cookie_path', $cookiePath);

You can just insert these lines at a very early place in the UNB source code, like at the beginning of forum.php.
Be sure to clear out all cookies from the domain in your browser. They will be in the way when testing the new code.

Works like a charm. Thanks!
Dixi et liberavi
Avatar
Reply · Quote rvwsak #7
Member since Jul 2005 · 107 posts · Location: Norway
Group memberships: Members
Show profile · Link to this post
In reply to post #5
Quote by Yves:
Please consider opening a new thread for a different topic.
I have no idea what this could come from, with your description.

OK. I'll do some more experimenting and open a new thread later if necessary.
Dixi et liberavi
Avatar
Reply · Quote Yves (Administrator) #8
User title: UNB developer & webmaster
Member since Jan 2004 · 3740 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #6
This has been added as a new config option with today's version. (Whenever today's version will be released next.) See the change log.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
Reply · Quote Alan W (Guest) #9
No profile available.
Link to this post
Thanks for the fix, I've been having some users log in as other users too and tried the cookie code. Unfortunately users cannot log out now, is there any code I can use to destroy the cookies?
Avatar
Reply · Quote Yves (Administrator) #10
User title: UNB developer & webmaster
Member since Jan 2004 · 3740 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
That's a problem because your users now have two different cookies and only one of them is used (set and deleted) by the code but both can be read. You'd need to tell your users to delete all cookies for your domain to log out again.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please note the verification code from the picture into the text field next to it.
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Reply
Go to forum
This board is powered by the Unclassified NewsBoard software, 20100516-dev, © 2003-10 by Yves Goergen
Page created in 300 ms (256 ms) · 94 database queries in 156 ms
Current time: 2010-07-30, 10:50:42 (UTC +02:00)