gpt4 book ai didi

php - 如何回显 session 数据以查看配置文件

转载 作者:行者123 更新时间:2023-11-29 20:11:38 25 4
gpt4 key购买 nike

如何使用 codeigniter 回显 session 数据以查看个人资料或帮助我通过 session 传递 id 来获取用户个人资料

Controller

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class User extends CI_Controller
{
function __construct()
{
// Call the Model constructor
parent::__construct();
$this->load->database();
$this->load->library('session');
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->model('User_Model');
$this->load->helper('url');
$this->load->library('parser');
}

public function index()
{
$this->load->view('login');
}
public function register()
{
$this->load->view('Register');
}
public function Save()
{
$this->form_validation->set_rules('email', 'email', 'required');
if ($this->form_validation->run() == false)
{
echo 'Please enter correct email.';
exit;
}

$this->form_validation->set_rules('password', 'password', 'required');
if ($this->form_validation->run() == false)
{
echo 'Please enter password.';
exit;
}

if ($this->form_validation->run() == true)
{
$email = $this->input->post('email');
$password = md5(trim($this->input->post('password')));
$res = $this->User_Model->Save($email,$password);
exit;
}
}
public function Login()
{
$this->form_validation->set_rules('email', 'email', 'required');
if ($this->form_validation->run() == false)
{
echo 'Please enter correct email.';
exit;
}

$this->form_validation->set_rules('password', 'password', 'required');
if ($this->form_validation->run() == false)
{
echo 'Please enter password.';
exit;
}

if ($this->form_validation->run() == true)
{
$email = $this->input->post('email');
$password = md5(trim($this->input->post('password')));
$res = $this->User_Model->login($email,$password);
echo $res;
exit;
}
}
public function dashboard()
{
$this->load->view('welcome');
}

public function logout()
{
$this->session->sess_destroy();
redirect(base_url().'index.php/User/');
}
}
?>

最佳答案

  1. 使用原始 php,您可以使用 $_SESSION 检查 session 数据

  2. 在 codeigniter 中,您可以使用 print_r($this->session->all_userdata()); 检查 session 数据

关于php - 如何回显 session 数据以查看配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40071812/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com