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

Dizkus

Bottom
Single Login and User Session across multiple sites
  • Posted: 20.05.2005, 20:22
     
    Gericht
    rank:
    Helper Helper
    registered:
     May 2002
    Status:
    offline
    last visit:
    13.10.06
    Posts:
    274
    When I say "Multiple Sites" I don't mean "Multi-Sites", I mean that I have several installations sharing some of the same DB tables.

    I had to use this method because the MultiSites module did not work for me.

    This is for testing on a main domain and a sub-domain (or as many sub-domains as you'd like) using PN 7.50

    All PN installations are installed in the same DB.
    The main domain is installed with the prefix 'nuke'
    The subdomain is installed with the prefix 'nuke_sub'



    **(1)**


    In pntables.php I've changed all user tables:

    _group_membership
    _group_perms
    _groups
    _user_data
    _user_perms
    _user_property
    _userblocks
    _users

    to share the same DB

    and set the $session_info to

    Code

    $session_info = 'nuke_session_info';
    (where nuke from 'nuke_session_info' is the prefix of my main DB) which will have the two sites looking in the same place for the user's sesssion info.
    (respect to Serenarules for this part)


    **(2)**



    In modules>NS-User>tools.php change the line in function docookie to

    Code

    setcookie("user", "$info", time() + 15552000, ".yourdomain.com", "/");
    so that the cookies for each site are stored in the same manner (rather than each being stored for their respective domain)
    (respect again to Serenarules for this part)



    **(3)**



    In includes>pnSession.php set

    Code

    $domain = preg_replace('/^[^.]+/','',$host);
            ini_set('session.cookie_domain', '.yourdomain.com');

    which does something I'm not certain of, but that drak posted in his instructions on staying logged in across multiple sites here: http://news.postnuke…om/Article2628.html



    **(4)**



    Finally, flush (aka Truncate) the nuke_session_info table and you should be good to go.



    Please note that none of this is my own work; I've simply taken 2 people's posts on 3 threads and merged them into one.
    Goodluck :shock:

    --
    the china diaries
  • Posted: 05.09.2005, 13:45
     
    MACscr
    rank:
    Professional Professional
    registered:
     December 1969
    Status:
    offline
    last visit:
    10.01.08
    Posts:
    1631
    That didnt seem to make a difference for me unfortunately. What im trying to do is have all these urls use the same logins/sessions:

    http://absreport.com
    https://absreport.com
    http://www.absreport.com
    https://www.absreport.com
    http://secure.absreport.com/
    https://secure.absreport.com

    Any chance in this? I can get it to work fine (http/https) when its the same subdomain, but not when they are different.

    EDIT: nothing is different with any of these urls as far as what they point to. They are all the same site.
  • Posted: 05.09.2005, 13:56
     
    MACscr
    rank:
    Professional Professional
    registered:
     December 1969
    Status:
    offline
    last visit:
    10.01.08
    Posts:
    1631
    Woo hoo, got it working, just had to remove the period in front of the domain name. I noticed that there was that difference between the directions provided here and the ones he linked too. Thanks!!
  • Posted: 29.01.2007, 00:18
     
    underscrutiny
    rank:
    Freshman Freshman
    registered:
     January 2007
    Status:
    offline
    last visit:
    28.01.07
    Posts:
    2

    Gericht


    **(2)**



    In modules>NS-User>tools.php change the line in function docookie to

    Code

    setcookie("user", "$info", time() + 15552000, ".yourdomain.com", "/");
    so that the cookies for each site are stored in the same manner (rather than each being stored for their respective domain)
    (respect again to Serenarules for this part)


    Not sure whether I'm blind, or whether this applies to a previous version of PostNuke (I'm guessing maybe the latter as the default table prefix now seems to be PN rather than nuke)... but I can't find modules>NS-User>tools.php. I've been trying to get sessions working across multiples sites all day and this seems to be my stumbling block.

    Can anyone help out a n00b?

    edit - to clarify, I have everything else working but the cookies are still set separately for my subdomains. Can anyone tell me where to put the setcookie code? I'm using .764



    edited by: underscrutiny, Jan 28, 2007 - 09:21 PM
  • Posted: 29.01.2007, 02:50
     
    underscrutiny
    rank:
    Freshman Freshman
    registered:
     January 2007
    Status:
    offline
    last visit:
    28.01.07
    Posts:
    2
    In case anyone's as big an idiot as I am, I've solved my own 'problem'. Simply a case of ignoring step 2 and instead following step 3 more carefully! i.e. when uncommenting:

    $domain = preg_replace('/^[^.]+/','',$host);
    ini_set('session.cookie_domain', $domain);

    be sure to change $domain to '.yourdomain.com'

    Yep, I'm an idiot who can't read simple instructions!

Extensions Moderation

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula