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.
Status | New | ⇒ | Information Required |
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);
?>
I am closing this at this time due to lack of response
Status | Information Required | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-03-29 10:22:27 |
Closed_By | ⇒ | brianteeman |
The answer though is you need to call $session->initialise
Can you test this 943f2e9 fix please? I think it's a session bug we just fixed