国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home Backend Development PHP Tutorial CakePHP framework Session setting method

CakePHP framework Session setting method

Feb 25, 2017 pm 04:25 PM
cakephp session

The example in this article describes the CakePHP framework Session setting method. Share it with everyone for your reference, the details are as follows:

CakePHP Session storage options

CakePHP provides users with 3 ways to save Session data:

1. Temporary files in the CakePHP installation directory;
2. Use the default mechanism of PHP;
3. Or serialize to the database.

Corresponding settings In core.php they are:

define('CAKE_SESSION_SAVE', 'php');
# 設(shè)置為 'cake',保存session到 /cakedistro/tmp目錄
# 設(shè)置為 'php',采用PHP的缺省路徑
# 設(shè)置為 'database',

The PHP mechanism is used by default.

If you choose to use it in the database For storage, you need to create a table in the database. There is a sql script to create the database in /app/config/sql/sessions.sql.

No matter which Session storage method is chosen, the component method operation of CakePHP is basically the same :

CakePHP Session Component is used to interact with Session: including basic Session reading and writing, prompting errors through Session, issuing prompt messages, etc.

Session Component is the default in all Cake controllers Available.

check(string $name);

Check whether there is already a data item with $name as the key value in the Session.

del(string $name);<br>delete(string $name);

Delete the Session variable specified by $name.

error

Returns the most recent error generated by Cake Session Component, often used for debugging.

flash(string $key='flash');

Returns the last message set with setFlash() in Session. If $key is set, the most recently stored message in it will be returned.

read(string $name);

Returns the $name variable value.

renew

By creating a new seesion ID, deleting the original ID, and updating the information in the original Session to the new Session.

setFlash(string $flashMessage, string $layout='default', array $params, string $key='flash');

Set $flashMessage in The information is written to the Session (for subsequent flash() method to obtain).

If $leyout is set to "default", the message is stored as '

'.$flashMessage.'

'. If $layout is set to '', the message will be saved as is. If $layout is any other value, the message is saved in the Cake view in the format specified by $layout.

$params parameters will be given functionality in future versions.

$key allows the prompt message to be stored under the key, and flash() reads the message based on the key.

valid returns true when the Session is valid. It is best to use it before the read() operation to determine whether the session you want to access is indeed valid.

write(string $name, mixed $value);

Write the variables $name, $value into the session.

For more articles related to the CakePHP framework Session setting method, please Follow PHP Chinese website!

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

Undress AI Tool

Undress AI Tool

Undress images for free

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.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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 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.

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.

CakePHP Logging CakePHP Logging Sep 10, 2024 pm 05:26 PM

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

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.

CakePHP Services CakePHP Services Sep 10, 2024 pm 05:26 PM

This chapter deals with the information about the authentication process available in CakePHP.

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 ?

How to solve session failure How to solve session failure Oct 18, 2023 pm 05:19 PM

Session failure is usually caused by the session lifetime expiration or server shutdown. The solutions: 1. Extend the lifetime of the session; 2. Use persistent storage; 3. Use cookies; 4. Update the session asynchronously; 5. Use session management middleware.

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.

See all articles