|about us||consulting||our tools||3D Development||Whole Enterprise||FlockEffect||The Whole Human||EVS|
|Hack Joomla Cookie Domain for Moodle Cross-Login|
|Written by Ben Cheek | Monday, 16 August 2010 12:05|
When using jFusion to integrate Joomla and Moodle userbases (Joomla as master, Moodle as slave), I have often run into issues with the session cookie not being stored correctly. I've had the same issue with phpBB3 and MediaWiki integrations as well. Part of the issue is how Joomla creates cookies. In order to work in all cases, it's best if Joomla uses the cookie domain ".mysite.com" in all cases -- the domain most other software expects when recognizing session cookies.
Below are instructions on hacking Joomla to make this work. NOTICE: hacking Joomla's core files is not recommended for those who cannot troubleshoot any errors or who can't reverse the process. Updates of Joomla will likely overwrite these hacks and make portions of your site inaccessible, especially if you use Fantastico or another update script. This solution is based on mihajlovski's fix posted on the Joomla forums.
STEP 1: Fix Sessions
Find the following lines in /libraries/joomla/session/session.php
Add the following on a new line before session_start(); in both instances, replacing ".mysite.com" with your domian:
STEP 2: Fix Cookies
In session.php, look for the setcookie(...) function, and add '.mysite.com' as a parameter to each like this:
Do this also for all occurances of setcookie() in the following files:
/libraries/joomla/application/application.php (2 occurances)
STEP 3: Configure jFusion Plugin
Once these files are modified, you'll need some specific settings in the jFusion plugin for Moodle (Components >> JFusion >> Configuration). Specifically, in the "Dual Login cURL Options" need to be set as follows:
If you've been testing Joomla-Moodle Integration before you make these changes, you'll need to clear your browser cache, especially all your cookies. Otherwise, sesson cookies may still exist that will interfere with proper session creation.
Some browsers use stricter cookie rules (I occassionally have issues with the IE family not preserving sessions when Moodle takes over cookie maintenance). To help with this, I recommend specifying a cookie domain in Moodle as well. To do this in Moodle, go to Administration >> Server >> Session Handling and enter the same cookie domain you used above, like .mysite.com. Clear all browser cache and test the session transfer my logging into Joomla and clicking a link to your Moodle site. This will show if Joomla and jFusion are correctly creating a Moodle session cookie. Click a link to enter a course or page that requires login. If you are still logged in, Moodle is correctly picking up and preserving the session.
|Last Updated on Thursday, 02 September 2010 09:01|