ReUsing Joomla 3.x Login in WebApp

Hello,

i am trying to reuse the Joomla Login within my WebApp.
The Sessions are saved in a mySQL Table called joomla_session. Within this Table are columns for a session id, a timecode, a user id, a username, a client id and a marker for guests.

I assume i have to compare the browsers session id with the database session id to identify the logged in user.

Has anybody already tried this and can help here with some code snippets or can someone please tell me how i can reliable get the browsers/joomla session id of a logged in user?

Thank you in advance.

You’ll need to set a separate identifier of some kind. The SessionID in a web app are completely contained in the application itself.

I was hoping to somehow get the session id of the active joomla session, from the browsers cookie.

Perhaps. You’ll need to view the cookies for your site while logged into Joomla and see if it’s available in your web app. If the domains are identical, perhaps. Keep in mind that some cookies are set up to only be available when connected via https or even when the user is in a particular URI path. In other words, your mileage may vary.

I’m resurfacing this as I’ve been battling this “headache”. I was hoping to recreate the same. however for now, I’ve been able to authenticate the user against the Joomla table. I created a “generic” component at http://www.component-creator.com/en/. There is a free account. Very generic, no tables & no views. I’ve then butchered the controller.php in the component which returns the user ID, whether they’re blocked or active as well as the user groups they belong too as a json string.

That way, on my webapp, when the page attempts to authenticate it queries this component and gets the json string back. I have to add security stuff in due time.

I’m willing to share the php if anyone interested.

Any attempts to share the Joomla session ID haven’t been successful yet. :frowning:

You could use

$session = &JSession::getInstance();
$session_id = $session->getId();

in PHP and return your webapp url with the $session_id attached…how is the app initialized…via link in jooma? As an iframe in joomla?

[quote=87583:@Matthew Combatti]You could use

$session = &JSession::getInstance();
$session_id = $session->getId();

in PHP and return your webapp url with the $session_id attached…how is the app initialized…via link in jooma? As an iframe in joomla?[/quote]

I’ll have another fiddle. I had issues with getting the $session when I was authenticating with the app. It resides on a sub domain but on a different server (I tried link to, iFrame and direct launch as well), and I could get $Session when I did the URL in the same browser. I’ll play around some more :slight_smile:

Thanks for the help.

Having had some fun(!) with this yesterday, the session data stays within the browser, the app cannot remotely access it. Soo, if I decide to iframe it, I can hack the com_wrapper stuff to pass the logged in data etc.