Avatar of FourMat
FourMat

asked on 

Session Conflict between Joomla 3.x and OSCommerce

Question: Is there a way to disable sessions for Joomla 3 when loading the framework into an external script? Or make Joomla 3 sessions play nice with OSCommerce?

Situation: I am trying to load the a Joomla 3.x module into an OSCommerce installation and I'm am running into a session conflict where Joomla overrides the OSC, disabling OSC usability.

Background: I embedded the Joomla framework and module using the advice and instructions from several different locations and it seems to be working well.

 
  <?php

    define( '_JEXEC', 1 );
        define('JPATH_BASE', '../cms/');
    define( 'DS', DIRECTORY_SEPARATOR );
    require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
    require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
    //$mainframe =& JFactory::getApplication('site');
    $mainframe =& JFactory::getApplication('site',array('session'=>false));
    $mainframe->initialise();

    jimport( 'joomla.application.module.helper' );

    function renderModule ($positionName){
        $document =& JFactory::getDocument();
        $renderer = $document->loadRenderer('module');
        $db =& JFactory::getDBO();
        $db->setQuery("SELECT * FROM #__modules WHERE position='$positionName' AND published=1 ORDER BY ordering");
        $modules = $db->loadObjectList();
        if( count( $modules ) > 0 ){
            foreach( $modules as $module ){
                //just to get rid of that stupid php warning
                $module->user = '';
                $params = array('style'=>'xhtml');
                echo $renderer->render($module, $params);
        }  
       }
    }


echo renderModule('position-33');   
    ?>

Open in new window



The problem I now have is that the Joomla session is overriding the OSCommerce session.

I've added code to output the session information and this is what I get:

Before adding Joomla framework code:

Array
(
    [cart] => shoppingCart Object
        (
            [contents] => Array
                (
                )

            [total] => 0
            [weight] => 0
            [content_type] => 
            [shiptotal] => 0
        )

    [language] => english
    [languages_id] => 1
    [currency] => USD
    [navigation] => navigationHistory Object
        (
            [path] => Array
                (
                    [0] => Array
                        (
                            [page] => index.php
                            [mode] => NONSSL
                            [get] => Array
                                (
                                )

                            [post] => Array
                                (
                                )

                        )

                )

            [snapshot] => Array
                (
                )

        )

    [affiliate_ref] => 
    [affiliate_clickthroughs_id] => 
)

Open in new window


After adding Joomla framework code, no OSC session vari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GF0YSI7Tzo4OiJzdGRDbGFzcyI6MDp7fXM6OToic2VwYXJhdG9yIjtzOjE6Ii4iO31zOjE0OiIAKgBfYXV0aEdyb3VwcyI7YToyOntpOjA7aToxO2k6MTtpOjk7fXM6MTQ6IgAqAF9hdXRoTGV2ZWxzIjthOjM6e2k6MDtpOjE7aToxO2k6MTtpOjI7aTo1O31zOjE1OiIAKgBfYXV0aEFjdGlvbnMiO047czoxMjoiACoAX2Vycm9yTXNnIjtOO3M6MTM6IgAqAHVzZXJIZWxwZXIiO086MTg6IkpVc2VyV3JhcHBlckhlbHBlciI6MDp7fXM6MTA6IgAqAF9lcnJvcnMiO2E6MDp7fXM6MzoiYWlkIjtpOjA7fX19czo5OiJzZXBhcmF0b3IiO3M6MToiLiI7fQ==
)

Open in new window


I have tried inserting the joomla framework before and after the session call for OSCommerce, but it overrides it. I have also tried to disable a Joomla session when the framework is loaded into OSC. Apparently there is something fundamental I'm not understanding about sessions.

Is there a way to make these two separate types of session systems play nice together? If there is no way to make the systems play together, is there a way to disable sessions for Joomla 3 when loading the framework into an external script?
JoomlaPHPE-CommerceWeb DevelopmentBootstrap

Avatar of undefined
Last Comment
FourMat

8/22/2022 - Mon