Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't access the user object after upgrading to 3.5--all my code is broken #9514

Closed
mortonsean opened this issue Mar 22, 2016 · 4 comments
Closed

Comments

@mortonsean
Copy link

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.

@wilsonge
Copy link
Contributor

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

@andrepereiradasilva
Copy link
Contributor

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);
?>

@brianteeman
Copy link
Contributor

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.

@wilsonge
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants