?
avatar mortonsean
mortonsean
22 Mar 2016

Steps to reproduce the issue

Using php in an iframe. I was previously able to get the user id with

define( 'JEXEC', 1 );
define( 'VALID_MOS', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE
).'/..'));
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->initialise();
$session =& JFactory::getSession();
$user = JFactory::getUser();

but since upgrading, I get a "Failed to start the session because headers have already been sent" on pages that were working fine before.

Votes

# of Users Experiencing Issue
0/1
Average Importance Score
5.00

avatar mortonsean mortonsean - open - 22 Mar 2016
avatar wilsonge
wilsonge - comment - 22 Mar 2016

Can you test this 943f2e9 fix please? I think it's a session bug we just fixed

avatar brianteeman brianteeman - change - 22 Mar 2016
Status New Information Required
avatar andrepereiradasilva
andrepereiradasilva - comment - 22 Mar 2016

since the code posted seems to have been cropped by github, just to test, tried 3.5.0 without any patch with the following code and it worked.

To test, i created a file in the joomla root folder test.php with the following content

<?php
define( '_JEXEC', 1 );
define( '_VALID_MOS', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__)));
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->initialise();
$session = JFactory::getSession();
$user = JFactory::getUser();
// dump values
var_dump($session);
var_dump($user);
?>
avatar brianteeman
brianteeman - comment - 29 Mar 2016

I am closing this at this time due to lack of response


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9514.

avatar brianteeman brianteeman - change - 29 Mar 2016
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2016-03-29 10:22:27
Closed_By brianteeman
avatar brianteeman brianteeman - close - 29 Mar 2016
avatar brianteeman brianteeman - close - 29 Mar 2016
avatar wilsonge
wilsonge - comment - 29 Mar 2016

The answer though is you need to call $session->initialise

Add a Comment

Login with GitHub to post a comment