codeigniter - PHP session在页面间传递的问题
PHP session在页面间传递的问题:
前提: 使用codeIgniter的框架, 使用PHP自带的session
1. 在纯apache服务器上没有问题
2. 在Nginx的apache模式下, 独立于codeIgniter框架外的页面无问题
3. 在Nginx的apache模式下, 置于codeIgniter框架内的页面, 页面间session的传递有问题, 即一个页面设置session, 另一个页面无法读取到前一个页面设置的session
Nginx的apache模式:LNAMP环境下,直接访问8889端口,基本等于忽略Nginx直接访问apache。使用LuManager
在Nginx的apache模式下, 独立于codeIgniter框架外的页面无问题
在Nginx的apache模式下, 置于codeIgniter框架内的页面, 页面间session的传递有问题, 即一个页面设置session, 另一个页面无法读取到前一个页面设置的session
回复内容:
PHP session在页面间传递的问题:
前提: 使用codeIgniter的框架, 使用PHP自带的session
1. 在纯apache服务器上没有问题
2. 在Nginx的apache模式下, 独立于codeIgniter框架外的页面无问题
3. 在Nginx的apache模式下, 置于codeIgniter框架内的页面, 页面间session的传递有问题, 即一个页面设置session, 另一个页面无法读取到前一个页面设置的session
Nginx的apache模式:LNAMP环境下,直接访问8889端口,基本等于忽略Nginx直接访问apache。使用LuManager
在Nginx的apache模式下, 独立于codeIgniter框架外的页面无问题
在Nginx的apache模式下, 置于codeIgniter框架内的页面, 页面间session的传递有问题, 即一个页面设置session, 另一个页面无法读取到前一个页面设置的session
Php 在各个请求之间传递的是session id, 无非就是三种方式:
- 通过http请求中的Cookies头部来传递session id
- 通过http get请求来传递session id, 也就是将session id 放在url参数中
- 通过http post请求来传递session id,也就是将session id 放在post数据中进行传递
我在自己的博客中结合http写了一篇阐述php session本质的文章 - 你必须了解的session的本质。
有兴趣的话,你可以细细读下,如果发现有什么不妥之处,你可以在评论中指出来,我会核对加以纠正。 希望更志同道合的朋友一起分享技术思想。
这种问题为什么不把session的内容放到memcache里面呢?
首先这种方式是属于第三方的,不存在平台间获得session的异常;其次可以设置精确的过期时间,且存取速度很快,并且数据不落地,不必考虑原生session那种file存放方式带来的困扰和放到数据库里面存在的存取速度问题;访问量不大的情况下一台64G内存的server即可搞定,小弟愚见,请指正

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.
