这篇文章主要介绍了CodeIgniter中使用cookie的三种方式,非常简洁实用,需要的朋友可以参考下
cookie在php程序设计中应用十分广泛,本文所述codeigniter中使用cookie主要有以下三种方式,读者可以根据自身项目需求酌情采用。
第一种方式:采用php原生态的方法设置的cookie的值
setcookie("user_id",$user_info['user_id'],86500); setcookie("username",$user_info['username'],86500); setcookie("password",$user_info['password'],86500); //echo$_COOKIE['username'];
第二种方式:通过CI框架的input类库设置cookie的值
系统前端采用可视化布局,能自动适应不同尺寸屏幕,一起建站,不同设备使用,免去兼容性烦恼。系统提供列表、表格、地图三种列表显示方式,让用户以最快的速度找到所需行程,大幅提高效率。系统可设置推荐、优惠行程,可将相应行程高亮显示,对重点行程有效推广,可实现网站盈利。系统支持中文、英文,您还可以在后台添加新的语言,关键字单独列出,在后台即可快速翻译。
150
$this->input->set_cookie("username",$user_info['username'],60); $this->input->set_cookie("password",$user_info['password'],60); $this->input->set_cookie("user_id",$user_info['user_id'],60); //echo$this->input->cookie("password");//适用于控制器 //echo$this->input->cookie("username");//适用于控制器 //echo$_COOKIE['username'];//在模型类中可以通过这种方式获取cookie值 //echo$_COOKIE['password'];//在模型类中可以通过这种方式获取cookie值
第三种方式:通过CI框架的cookie_helper.php辅助函数库设置cookie的值
set_cookie("username",$user_info['username'],60); set_cookie("password",$user_info['password'],60); set_cookie("user_id",$user_info['user_id'],60); //echoget_cookie("username");
,
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号