Joomla session integration possible?

Discussion in 'Integration' started by clee, Sep 23, 2009.

  1. clee

    clee New Member

    Joined:
    Aug 27, 2008
    Messages:
    14
    I'm trying to build a simple Joomla 1.5.x module to detect the aMember session.

    I'm not integrating the user system so I have no protected content within Joomal! I simply want to display the aMember session variables within Joomla!
    I've tried hard coding this into my Joomla! template without success. Any help?

    Code:
    <?php
    session_start();
    $user = $_SESSION['_amember_user'];
    if ($user['member_id'] > 0){
     * *print "Hello $user[name_f] $user[name_l] <br>\n";
     * *print "Your E-Mail address is $user[email] <br>\n";
     * *print "Your subscription status is $user[status] <br>\n";
    } else {
     * *print "You are not logged-in";
    }?>
    
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    With joomla 1.0.x you used to be able to use the amember session info.
    But 1.5.x seems to destroy it. I tried a few times but eventually gave up.
    Please post if you find a solution.

    David
  3. clee

    clee New Member

    Joined:
    Aug 27, 2008
    Messages:
    14
    Still no solution. I'm thinking about hacking the session.php file..
  4. curlyroger

    curlyroger New Member

    Joined:
    Dec 15, 2008
    Messages:
    19
    I believe that I made it work, but I'm not sure of the security implications.

    In libraries/joomla/session/session.php, find the __construct function (around line 88).

    It took me 4 hours to figure out, but all I did was add this at the top:

    Code:
    function __construct( $store = 'none', $options = array() )
    	{
    	if (strpos($_SERVER["REQUEST_URI"],'/administrator')===FALSE) { 
    			session_start();
    			return;
    		}
    
            // Everything else below no longer matters
    
    The admin doesn't like it when I do this, so I have that test in there for it. All we are doing is skipping the whole constructor. When Joomla constructs its session stuff, it doesn't blow away the amember session, it just resumes it. Now it seems like I can read amember session variables all day in Joomla.

    HOWEVER! I am NOT using Joomla user accounts at all. Joomla is basically just for site design and content management, so I figure any sort of Joomla-specific cookie stuff wouldn't apply for me. This is why I'm okay just hacking it that way. I have no idea what the implications could be if you are actually using Joomla sessions for anything (components, users, etc)

    I'm curious to hear others thoughts on the implications and/or if it works for them.
  5. laguitar

    laguitar aMember Pro Customer

    Joined:
    Jun 16, 2009
    Messages:
    12
    Hi CurlyRoger,

    Thanks for posting this solution. It works well for reading amember session variables without joomla interrupting. However, when I log in to joomla backend, (as you mentioned the possibility in your post) after a short while I get the login screen.

    Just wondering if you or anyone else had any possible solution for this?

    Any thoughts/suggestions are much appreciated.
  6. youjoomla

    youjoomla Member

    Joined:
    May 15, 2007
    Messages:
    61
    working on overriding the constructor class will post if I find better solution, it should works ince the constructor is public so will see

Share This Page