[英]How to move to Dashboard welcome screen through logged-in dashboard breadcrumb, using session in Codeigniter?
I have created a login with specific array value in CodeIgniter, the dashboard loads after providing the correct credentials, along with login;我在 CodeIgniter 中创建了一个具有特定数组值的登录,仪表板在提供正确的凭据以及登录后加载; Breadcrumb is displayed with the title 'HOME/Dashboard'.How to view the main dashboard page when the breadcrumb Home is clicked.面包屑显示标题为“主页/仪表板”。单击面包屑主页时如何查看主仪表板页面。 If I'm creating seperate route for the home, the dasboard homepage is getting loaded even if logged-out.如果我正在为主页创建单独的路线,即使已注销,仪表板主页也会被加载。
Here is the code for Controller这是 Controller 的代码
public function adminLogin()
{
$username = $this->input->post('username');
$adminRecognition = $this->input->post('adminRecognition');
$password = $this->input->post('password');
if($username=='some_user' && $adminRecognition == '01234' && $password == 'some_pass')
{
$this->session->set_userdata(array('username'=>$username));
$this->load->view('DashboardView/super_admin/superAdmin_View');
}
else
{
$data['error'] = 'Please enter a valid Credentials';
$this->load->view('admin_login_portal/admin_portal',$data);
}
}
public function adminLogout()
{
$this->session->unset_userdata('username');
$this->load->view('admin_login_portal/admin_portal');
}
Here is the code in the breadcrumb that loads at the other page这是在其他页面加载的面包屑中的代码
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0">Dashboard</h1>
</div><!-- /.col -->
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item active">Dashboard</li>
</ol>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div>
How to redirect with admin login page if session is not active, and how the home page would load on clicking the HOME link in the breadcrumb?如果 session 未激活,如何使用管理员登录页面重定向,以及单击面包屑中的主页链接时如何加载主页?
A redirection link can be created on href(s) of the other page with the name of a Controller performing a similar action.可以在另一个页面的 href(s) 上创建一个重定向链接,名称为 Controller,执行类似的操作。 Here is the example of the code:以下是代码示例:
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0">Dashboard</h1>
</div><!-- /.col -->
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="<?php echo base_url(); ?>name_of_the_Controller/method_redirecting_to_dashboard_home_view">Home</a></li>
<li class="breadcrumb-item active">Dashboard</li>
</ol>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div>
To check that the link is not misused with direct redirection, you can write the following Controller要检查链接是否被直接重定向误用,可以编写以下 Controller
public function superAdminDashboardView()
{
if(!$this->session->userdata('username'))
{
$this->load->view('admin_login_portal/admin_portal');
}
else
{
$this->load->view('DashboardView/super_admin/superAdmin_View');
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.