Accessing session data outside Joomla

前端 未结 15 1504
小鲜肉
小鲜肉 2020-12-08 03:36

I am trying to run an application outside Joomla (not as a plugin) and I would like to access the logged in user\'s information (userid). I am wondering how should I go abou

15条回答
  •  醉话见心
    2020-12-08 04:07

    I cannot tell you how Joomla with versions above 1.5 does that but in Joomla 1.5 here is how you do that: ( I am sure for other versions procedure is very similar )

    Joomla generates Unique session id for front-end of the website and back-end. To access session data all you need is know the session id.

    In joomla configuration file there is a parameter called "secret"

    For back-end this is how you generate session id:

    $session_id = md5( md5( JConfig::$secret.'administrator' ) );
    

    and for front end:

    $session_id = md5( md5( JConfig::$secret.'site' ) );
    

    After this a simple query

    mysql_query( 'SELECT `data` FROM jos_session WHERE session_id="'.$sessionId.'"  )
    

    will give you access to session data. All you need is to decrypt it with session_decode and session data will be in $_SESSION variable.

    Don't forget to put session_start before session_decode otherwise it will not work

提交回复
热议问题