Home > Backend Development > PHP Tutorial > Common Session Problems in PHP_PHP Tutorial

Common Session Problems in PHP_PHP Tutorial

WBOY
Release: 2016-07-13 10:59:41
Original
1134 people have browsed it

1. How to set up a long-lived session?
Set session.cookie_lifetime and session.gc_maxlifetime longer.

2. Why is an error reported when initializing the session?
a, check the storage path of the session file, whether the path is correct, and whether the operation permission is sufficient
b. Check whether there is html content output before session initialization

3. When the client disables cookies, will the session be affected?
When the client rejects the use of cookies. It will bring a lot of inconvenience:
PHP will automatically add sessionId parameters to links and forms on the page. To ensure session
Continue, but this time, manually enter the same address multiple times on a browser, session
Will be considered as multiple sessions instead of one.

4. Why does my session expire after a few minutes?
1. Check whether the browser's cookies are enabled. If not, check
Whether the system allows using url to pass sessionID, and finally check the url_rewriter.tags setting
2. Check the session’s garbage marking time and recycling probability

5. How to store my session in the database?
Use session_set_save_handler("open", "close", "read", "write", "destroy", "gc")
Customize your own approach.

6. How to use session to get the current number and list of users?
If the session is stored in the database, it will be easy to implement, but no matter what
The data obtained by this method may not be accurate data.

7. Why does the content of the form I filled out disappear after I go back?
Check whether there is an action to initialize the session in the script. If so, use:
session_cache_limiter('private, must-revalidate');

6. How to use session to control the cache of web pages?
Adjust session.cache_limiter, session.cache_expire

8. I use session to manage sessions. Will it be affected if the same account is logged in on two machines at the same time?
There will be no impact. Because these are two sessionIDs. That means there are two session files on the server
to ensure their respective sessions.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631894.htmlTechArticle1. How to set up a long-lived session? Set session.cookie_lifetime and session.gc_maxlifetime longer. 2. Why is an error reported when initializing the session? a, check...
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template