Find joomla session variables for php

1

A client has a site made in joomla, and I have to integrate the login that it does on your site to my site in php. But I do not know how to get the joomla session variables. How can I get them? Or how can I see their names?

    
asked by anonymous 28.08.2014 / 15:47

3 answers

2

Within a joomla PHP file, already initialized and preferably logged in (if you work with joomla login), put the following code:

<pre>
<?PHP print_r($_SESSION); ?>
</pre>

This way you will see all the session variables initialized up to that point. To use, just access:

<?PHP echo $_SESSION["nome_da_variavel_mostrada"]; ?>

Remembering that this needs to be posted on the JOOMLA website. For you to pass these session variables from his site to yours, it would be interesting if everything were on the same server and domain, so the browser maintains the same session ID.

    
30.08.2014 / 15:09
2

With this code you will have the Joomla session information

<?php
// Recuperando Sessão do usuário Joomla
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
$path = "\xampp\htdocs\seuprojeto";  //caminho da instalação do Joomla
define('JPATH_BASE', $path);
require_once JPATH_BASE . DS . 'includes' . DS . 'defines.php';
require_once JPATH_BASE . DS . 'includes' . DS . 'framework.php';

$mainframe =& JFactory::getApplication('site');
$db = &JFactory::getDBO();
$mainframe->initialise();
$user =& JFactory::getUser( );


echo $user->id;  //imprime id do usuário
echo $user->name; //imprime nome do usuário
echo $user->password; // Imprime senha do usuário
    
07.11.2016 / 13:00
0

To give you a dump in the current Joomla Session, just make the following code:

$session = JFactory::getSession();
var_dump($session);

And from this object, you can get the information you want.

    
09.11.2016 / 21:53