Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
How to log in once for all sites (multisite login)
  • Posted: 21.05.2003, 18:53
     
    Dragonfly
    rank:
    Freshman Freshman
    registered:
     October 2002
    Status:
    offline
    last visit:
    25.05.03
    Posts:
    20
    Dear folks,
    after looong time searching, trying and whining, I've found finally a solution to make multisite login easy:

    The Problem:
    You run PostNuke multisite under different subdomains (like modules.postnuke.com, block.postnuke.com, etc.) and you want people to enable to log in once to gain access to all sites (in contrast to postnuke.com where users do need to login each time they switch between sites). So assuming you are sharing all necessary user- and session-tables, here's the solution:

    As already proposed, the cookies are the problem. They need to carry a domain name like postnuke.com and NOT blocks.postnuke.com
    Well, now I've tried this solution and it worked for me - I've found it at http://noc.postnuke.…p?type=snippet&id=2:

    Quote

    The problem with the current default multi site setup on PostNuke is you have to log in at each site. Trying to duplicate what happens at http://www.postnuke.com I did the following. I shared my sessions table. This resulted in the Who's Online blocks recognising you were on all the sites but you weren't logged in. This wasn't good. The logged in state is "kept" in a cookie. I used the viewhtml script at the following URL to view the HEAD: http://www.rexswain.com/httpview.html The result was as followed: "Set-Cookie:·POSTNUKESID=2569a63ee8a11dc9475fa26b200bd559;·expires=Wed,·02-Feb-28·18:45:27·GMT;·path=/" Notice the lack of a domain name in the cookie. I would like that to be *.example.com. Searching the PostNuke files i found that the cookie is set in NS-User/tools.php on line 67 (cvs version) in the function docookie(). That line states setcookie("user","$info",time() + 15552000); Looking at the PHP manual i see that domain, path etc are optional and path is default the dir the cookie is set in. Reading further i see that sub domains can be set like this: "To make the cookie available on all subdomains of example.com then you'd set it to '.example.com'. The . is not required but makes it compatible with more browsers." So i changed line 67 to setcookie("user","$info",time() + 15552000,"/",".example.com")


    So, thanks to roderik who've proposed this solution !!

    Now I just have to figure out how to not-share tables...but this is a different issue :D

    Mel
  • Posted: 21.06.2003, 01:02
     
    jcwilson
    rank:
    Freshman Freshman
    registered:
     February 2003
    Status:
    offline
    last visit:
    06.10.03
    Posts:
    28
    This fix is not complete without the additional change as included below.

    Quote

    I have had this working beautifully a couple of times - the documentation i used was this one - here

    The part that i think will help you is just above point 9 - and is the key to setting multiple sites with same login - it has to do with the cookie domain etc - read this document it will help you set up the prefix as well - note point nine - it is the opposite to the way it says to do it in the ppostnuke instructions.

    here it is.

    Quote:
    ANSWER: The reason your blocks won't work is because you were sharing only the user tables and the private messages table. If you want to get your setup to work, reverse the process, keep $prefix to 'nuke' and only override the tables you wish to separate in the subsites. In my setup, I keep everything shared with the main site nuke_ tables, except for mom_module_vars and dad_module_vars (hardcoded in parameters/mom.yourdomain/$pntable and parameters/dad.yourdomain/$pntable) - then, all the blocks would work, and each site can have its own theme. HOWEVER, there is an inconvenience to the user having to re-login when they switch from mom.yourdomain.com to dad.yourdomain.com - if you want the system to remember the same user, go to PostNuke core includes\pnSessions.php and modify $domain to hardcode it to be $domain = ".yourdomain.com"; (Thank you to Dracos on PostNuke Support IRC)!


    hope it helps - leave a note if it works
    _________________
    http://brianhouston.com
    http://citychurchbelfast.org
    http://ywamni.com
    http://god-life.com
    http://lucyoman.co.uk

Extensions Moderation

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula