Table of Contents
回复内容:
Home Backend Development PHP Tutorial codeigniter - PHP session在页面间传递的问题

codeigniter - PHP session在页面间传递的问题

Jun 06, 2016 pm 08:52 PM
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框架外的页面无问题

codeigniter - PHP session在页面间传递的问题

在Nginx的apache模式下, 置于codeIgniter框架内的页面, 页面间session的传递有问题, 即一个页面设置session, 另一个页面无法读取到前一个页面设置的session

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框架外的页面无问题

codeigniter - PHP session在页面间传递的问题

在Nginx的apache模式下, 置于codeIgniter框架内的页面, 页面间session的传递有问题, 即一个页面设置session, 另一个页面无法读取到前一个页面设置的session

codeigniter - PHP session在页面间传递的问题

Php 在各个请求之间传递的是session id, 无非就是三种方式:

  1. 通过http请求中的Cookies头部来传递session id
  2. 通过http get请求来传递session id, 也就是将session id 放在url参数中
  3. 通过http post请求来传递session id,也就是将session id 放在post数据中进行传递

我在自己的博客中结合http写了一篇阐述php session本质的文章 - 你必须了解的session的本质。

有兴趣的话,你可以细细读下,如果发现有什么不妥之处,你可以在评论中指出来,我会核对加以纠正。 希望更志同道合的朋友一起分享技术思想。

codeigniter - PHP session在页面间传递的问题

这种问题为什么不把session的内容放到memcache里面呢?
首先这种方式是属于第三方的,不存在平台间获得session的异常;其次可以设置精确的过期时间,且存取速度很快,并且数据不落地,不必考虑原生session那种file存放方式带来的困扰和放到数据库里面存在的存取速度问题;访问量不大的情况下一台64G内存的server即可搞定,小弟愚见,请指正

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

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

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

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

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

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

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

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

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

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

CakePHP Working with Database CakePHP Working with Database Sep 10, 2024 pm 05:25 PM

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

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

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

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

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

See all articles