我读到了将codeigniter会话存储到数据库中的内容。当我听到codeigniter会话被保存到cookie中,并且由于我的网站使用会话进行身份验证和设置权限,我非常担心所以我设计了代码来检查cookie的工作方式:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class sess extends CI_Controller
{
public function loadsession()
{
$this->session->set_userdata('username','administrator');
$this->session->set_userdata('password','abcdef123456');
}
}
/* End of file sess.php */
/* Location: ./application/controllers/sess.php */
这是结果cookie(ci_session):
a%3A7%3A%7Bs%3A10%3A%22session_id%22%3Bs%3A32%3A%2298867177e69b4d33059c7517782bdfc9%22%3Bs%3A10%3A%22ip_address%22%3Bs%3A13%3A%22192.168.1.100%22%3Bs%3A10%3A%22user_agent%22%3Bs%3A120%3A%22Mozilla%2F5.0+%28iPhone%3B+U%3B+CPU+iPhone+OS+3_0+like+Mac+OS+X%3B+en-us%29+AppleWebKit%2F528.18+%28KHTML%2C+like+Gecko%29+Version%2F4.0+Mobil%22%3Bs%3A13%3A%22last_activity%22%3Bi%3A1373188924%3Bs%3A9%3A%22user_data%22%3Bs%3A0%3A%22%22%3Bs%3A8%3A%22username%22%3Bs%3A13%3A%22administrator%22%3Bs%3A8%3A%22password%22%3Bs%3A12%3A%22abcdef123456%22%3B%7D3ef00c243e040389e98ab204933d4c8c
包含原始数据:
用户名%22%3Bs%3A13%3A%22 管理员%22%3Bs%3A8%3A%22password%22%3Bs%3A12%3A%22 abcdef123456 %22%3B%7D3ef00c243e040389e98ab204933d4c8c
我不知道如何在firefox中更改cookie,但如果我这样做,它会欺骗服务器吗?怎么预防?在数据库中保存会话可以保护我免受此类欺诈吗?
答案 0 :(得分:2)