Yii Framework Forum: Handling Session timeout - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Handling Session timeout Rate Topic: -----

#1 User is offline   kuldeepkaundal 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 14-April 11

Posted 15 September 2011 - 07:33 AM

Hi,

I wanted to discuss an issue related to session logout in yii, which i feel is a common problem in many apps.
I am using CJuiTabs in my application that displays Ajax Content after the user logs into the system. The issue is that in-case the user logs out from the application from some other window or his session times out, and then clicks one of the tabs, at first instant the whole index layout is rendered as the view in the tab content area and then certainly the screen goes white, which shouldn't happen, the user must see login screen or should be redirected to login page in case his session has timed-out.

I looked around and found some solutions here http://danaluther.bl...ax-updates.html

But,the thing is that suppose you logout from one window, click at tab, you see the session timeout error, however, if you login again, the tabs view is rendered distorting site layout.

Is there a way to overcome this issue? Please suggest!

Thanks,
Kul.
0

#2 User is offline   kuldeepkaundal 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 14-April 11

Posted 22 September 2011 - 07:24 AM

View Postkuldeepkaundal, on 15 September 2011 - 07:33 AM, said:

Hi,

I wanted to discuss an issue related to session logout in yii, which i feel is a common problem in many apps.
I am using CJuiTabs in my application that displays Ajax Content after the user logs into the system. The issue is that in-case the user logs out from the application from some other window or his session times out, and then clicks one of the tabs, at first instant the whole index layout is rendered as the view in the tab content area and then certainly the screen goes white, which shouldn't happen, the user must see login screen or should be redirected to login page in case his session has timed-out.

I looked around and found some solutions here http://danaluther.bl...ax-updates.html

But,the thing is that suppose you logout from one window, click at tab, you see the session timeout error, however, if you login again, the tabs view is rendered distorting site layout.

Is there a way to overcome this issue? Please suggest!

Thanks,
Kul.


OK, I solved the issue by using above url like this:
class WebUser extends CWebUser
{
public function loginRequired()
{
$app = Yii::app();
$request = $app->getRequest();

$this->setReturnUrl( $request->getUrl() );

if ( $request->isAjaxRequest )
{
Yii::app()->user->logout();
echo "<script>alert('you need to login to perform this action!');window.location.reload();</script>";
} else {

if ( ($url = $this->loginUrl) !== null )
{
if (is_array($url))
{
$route=isset($url[0]) ? $url[0] : $app->defaultController;
$url=$app->createUrl($route,array_splice($url,1));
}
$request->redirect($url);

}
else
throw new CHttpException(403, Yii::t('yii', 'Login Required'));
}
}
}
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users