Custom Sessions with Joomla

后端 未结 7 1231
小蘑菇
小蘑菇 2020-12-30 17:45

I\'ve trying to build Joomla into my existing website so I can use it for premium content.

I\'ve already got a custom-built authentication system that sets my own

相关标签:
7条回答
  • 2020-12-30 18:43

    Joomla will most likely initialize it's own session (we'll call it session "B") separate from the other system you're talking about which determines if the user gets the "premium" session (we'll call this session "A"). Once session "B" starts, I don't think it will be possible for session "B" to access information in session "A".

    My suggestion for getting around this would be to write the session handling code in pure PHP and run that code before Joomla loads it's own session. That way when you run session_start() it should catch session "A".

    A good way to get this into Joomla would be to write a "System" plugin and call the function "onAfterInitialise" this function get's called before Joomla has even setup it's session (at least, I'm pretty sure about that.. haha).

    <?php
    // no direct access
    defined( '_JEXEC' ) or die( 'Restricted access' );
    
    jimport( 'joomla.plugin.plugin' );
    
    class  plgSystemPremium extends JPlugin
    {
        function onAfterInitialise() {
            // ... load session
            // if premium user, return
            // else, redirect user to a registration page or whatever
        }
    }
    ?>
    
    0 讨论(0)
提交回复
热议问题