I have a custom component that has a simple form, and I'm struggling to manage session timeouts. If the user clicks another link, they are automatically redirected by Joomla. They are redirected to the login component, and upon successful login, they go to the page that they last clicked. This is exactly what I want.
However, the problem lies in the form. If the user doesn’t understand that they are filling out this form and clicking the submit button, they remain on the same page with the default session timeout message. Why is it not being redirected to the login component?
I think I need to handle this case in my code, so when my form is submitted, it calls this function in my controller:
function process()
{
$user = JFactory::getUser();
if ($user->id)
{
}
else
{
JError::raiseWarning( 100, JText::_('You have timed out. Please login again.') );
JFactory::getApplication()->redirect(JRoute::_('my-account'));
}
}
, Joomla . , .
$session = JFactory::getSession();
if ($session->isActive())
{
}
else
{
JError::raiseWarning( 100, JText::_('You have timed out. Please login again.') );
JFactory::getApplication()->redirect(JRoute::_('my-account'));
}
?