第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

會話在 codeigniter 框架中不起作用

會話在 codeigniter 框架中不起作用

PHP
喵喵時光機(jī) 2023-09-15 09:40:29
我是 Codeigniter 的新手。以使用codeiginiter.一切都很好,但會議無法滿足我的需要。我想要的是:-非登錄用戶也可以看到只有登錄用戶才能看到的私人區(qū)域。這是我的代碼:login.php 控制器defined('BASEPATH') or exit('No direct script access allowed');class Login extends CI_Controller{? ? public function __construct()? ? {? ? ? ? parent::__construct();? ? ? ? if ($this->session->userdata('hospital_email')) {? ? ? ? ? ? redirect('private_area');? ? ? ? }? ? ? ? $this->load->library('form_validation');? ? ? ? $this->load->library('encryption');? ? ? ? $this->load->model('login_model');? ? }? ? function index()? ? {? ? ? ? $this->load->view('view/login');? ? }? ? function validation()? ? {? ? ? ? $this->form_validation->set_rules('hospital_email', 'Email Address', 'required|trim|valid_email');? ? ? ? $this->form_validation->set_rules('pass', 'Password', 'required');? ? ? ? if ($this->form_validation->run()) {? ? ? ? ? ? $result = $this->login_model->can_login($this->input->post('hospital_email'), $this->input->post('pass'));? ? ? ? ? ? if ($result == '') {? ? ? ? ? ? ? ? redirect('private_area');? ? ? ? ? ? } else {? ? ? ? ? ? ? ? $this->session->set_flashdata('message', $result);? ? ? ? ? ? ? ? redirect('view/login');? ? ? ? ? ? }? ? ? ? } else {? ? ? ? ? ? $this->index();? ? ? ? }? ? }}
查看完整描述

2 回答

?
子衿沉夜

TA貢獻(xiàn)1828條經(jīng)驗 獲得超3個贊

我不知道你的意思,因為你沒有提供更多細(xì)節(jié)。但我有關(guān)于如何檢查會話值的簡單解決方案。像這樣


改變函數(shù)index()Private_area.php


$data['user'] = $this->session->userdata('hospital_email');

$this->load->view('private_area', $data);

在你看來private_area.php


<?php

? ? echo '<br /><br /><br /><h1 align="center">Welcome '.$user.'</h1>';

? ? echo '<p align="center"><a href="private_area/logout">Logout</a></p>';

?>


查看完整回答
反對 回復(fù) 2023-09-15
?
慕姐4208626

TA貢獻(xiàn)1852條經(jīng)驗 獲得超7個贊

還有另一種方法,


如何檢查會話值是否存在。


將此代碼放在視圖文件的頂部private_area.php:-


<?php

 $hospitalSession = $this->session->userdata('hospital_email');

if($hospitalSession['hospital_email']==''){

  redirect('Controller/method_name');   

}


 echo '<br /><br /><br /><h1 align="center">Welcome '.$user.'</h1>';

 echo '<p align="center"><a href="private_area/logout">Logout</a></p>';


?>


查看完整回答
反對 回復(fù) 2023-09-15
  • 2 回答
  • 0 關(guān)注
  • 113 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號