dos49618 2013-02-04 21:34
浏览 20
已采纳

Codeigniter 2.1 - 网站管理员部分的安全性

I have following measures to secure admin part:

  • Inside session I have following parts:

is_logged_in -> This can be 0 or 1

admin -> checks if the user is admin or not (values are 0 or 1)

And before any function inside admin controller or controller that have something to do with administration of the web site I call function to check if the user is logged in and is he an administrator? Is this enough? If it is not, what can I do to make admin part more secure?

  • 写回答

2条回答 默认 最新

  • douluogu8713 2013-02-04 22:24
    关注

    One simple form of session is

    $data = array(
        "admin" => $username,
        "is_logged_in"  => true
    );
    $this->session->set_userdata($data);
    

    But you can store in session also the id (if you need it) or something else.

    And if you want to check it, you can do it like this

    if (!isset($this->session->userdata['admin'])) {
        redirect('admin/login'); // for example
    }
    

    I prefer to store in DB the Session.

    For more, read http://ellislab.com/codeigniter/user-guide/libraries/sessions.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 三菱FX系列PLC上位机串口下指令置位M64和M65,这两条指令分别是什么呢?
  • ¥15 有关结冰模拟程序咨询
  • ¥15 ubuntu服务器配置dns域名后无法访问其他域名
  • ¥50 本人复制了一个关于股票指标的代码,但是运行失败,有没有人帮我解决一下
  • ¥50 用matlab和numeca做透平机械流体力学和热力学模拟 价格可议
  • ¥15 Unity3D WebView
  • ¥20 论文AlphaTensor复现(有偿)
  • ¥15 (有偿)在ANSYS中 .anf文件
  • ¥45 关于#芯片#的问题:组合逻辑电路设计
  • ¥15 基与机器学习和时间序列分析预测养老服务需求趋势