php session management

WBOY
Release: 2016-07-29 09:15:01
Original
1304 people have browsed it

php session management

1. Cookie

1. How to get the value in cookie?

Example jumps to a.php through index.php to get the corresponding value jason with the key name;

index.php code:


        
Copy after login
a.php code;


        
Copy after login
in Firefox Browser execution result:

php session management

2. How to access cookies through javascript?

Example displays results through pop-up box

  cookie知识点 
Copy after login
in index.php:

php session management

3. If the browser or user has disabled cookies, how to pass parameters between pages?

Example passes the value of b.php to c.php through URL parameters;

b.php code:


        
Copy after login
c.php code:


        
Copy after login
can obtain the corresponding value through $_GET The value of the key rose.

二.session:

1. Each time the browser is reopened, the server will assign a new session_id value to the client.


        
Copy after login
2. How to get the value corresponding to the session key?

Example jumps to a.php through index.php to display the value corresponding to the corresponding key of the session:

index.php code;


        
Copy after login
a.php code:


        
Copy after login
The last page jump The successful transfer shows: aili

3. What should I do if I want to destroy the session? (ps application scenario: clear login status after timeout)

PHP provides session_destroy() to destroy the session.

Insertsession_destroy() in index.php:


        
Copy after login
and then perform the operation. After jumping to the page, the result is: no name found.

The above introduces the session management of PHP, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!