If you want to return to your previous url after login or logout try this :
<?php
$this->redirect(Yii::app()->request->urlReferrer);
?>
To set the return url to be the url that was before the login page or registeration page was called you can put following code in views/layouts/main.php file :
<?php
//this checks id the controller action is not 'login' then it keeps the current url in returnUrl
if(CController::getAction()->id!='login')
{
Yii::app()->user->setReturnUrl(Yii::app()->request->getUrl());
}
?>
Hi, I have a home page containing a link to the order page which can be accessed after login. I have this code at the top of my order page:
After login, The user is taken to my account page with this code in the login page:
header("Location: myaccount.php");
What should I add so that when a person clicks order and is not logged in, he is taken to login, or sign up page, after which he is returned to the order pager where he wanted to go?
I am not using any CMS Platform.
The code at the order page is: session_start();
if(!isset($_SESSION['user_id'])){ header('location:login.php');}
Why do you put the code inside the view, not in the controller?