Home Backend Development PHP Tutorial session有关问题

session有关问题

Jun 13, 2016 pm 01:38 PM
insert session update write

session问题
遇到一个奇怪问题,
session处理。我用的是数据库,但问题就来了。
用户登录信息一直保存不了,跟踪后,发现多次调用session_write(),存入数据库的sql只有第一次数据是对的。然后不使用数据库存储,使用files存储。问题就没有了。似乎是处理session的脚本出了问题,但在本地测试又是好的。只有线上有问题。对照phpinfo打出的session信息,没发现什么不一样。这是什么情况呀?

------解决方案--------------------
关键看你是怎么写入数据库的啊。。你应该没更新最近的session
------解决方案--------------------
写入到数据库时出问题吧
------解决方案--------------------
session_write 中应判断对应的 session_id 是否存在
如存在,就执行 修改 update
否则执行插入 insert
------解决方案--------------------

探讨

引用:

session_write 中应判断对应的 session_id 是否存在
如存在,就执行 修改 update
否则执行插入 insert


在本地测试不会出现多次插入或更新的情况。

谢谢各位帮忙
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 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
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)

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.

Solution to PHP Session cross-domain problem Solution to PHP Session cross-domain problem Oct 12, 2023 pm 03:00 PM

Solution to the cross-domain problem of PHPSession In the development of front-end and back-end separation, cross-domain requests have become the norm. When dealing with cross-domain issues, we usually involve the use and management of sessions. However, due to browser origin policy restrictions, sessions cannot be shared by default across domains. In order to solve this problem, we need to use some techniques and methods to achieve cross-domain sharing of sessions. 1. The most common use of cookies to share sessions across domains

How to implement SMS login in Redis shared session application How to implement SMS login in Redis shared session application Jun 03, 2023 pm 03:11 PM

1. Implementing SMS login based on session 1.1 SMS login flow chart 1.2 Implementing sending SMS verification code Front-end request description: Description of request method POST request path /user/code request parameter phone (phone number) return value No back-end interface implementation: @Slf4j@ ServicepublicclassUserServiceImplextendsServiceImplimplementsIUserService{@OverridepublicResultsendCode(Stringphone,HttpSessionsession){//1. Verify mobile phone number if

Solution to high CPU usage of Microsoft compatibility telemetry Solution to high CPU usage of Microsoft compatibility telemetry Mar 16, 2024 pm 10:16 PM

When we use the win10 system, we sometimes encounter situations where the computer becomes stuck. Then when we check the background process, we find that a Microsoftcompatibilitytelemetry process takes up a particularly high amount of resources. So what is going on? Users can try to uninstall the third-party protection software and then try a clean boot to operate. Let this site carefully introduce to users the solution to the high CPU usage of Microsoftcompatibilitytelemetry. Solution to the high CPU usage of Microsoftcompatibilitytelemetry Method 1: Try after uninstalling the third-party protection software

KDE Plasma 6.1 brings many enhancements to the popular Linux desktop KDE Plasma 6.1 brings many enhancements to the popular Linux desktop Jun 23, 2024 am 07:54 AM

After several pre-releases, the KDE Plasma development team unveiled version 6.0 of its desktop environment for Linux and BSD systems on 28 February, using the Qt6 framework for the first time. KDE Plasma 6.1 now comes with a number of new features t

What are the differences between JavaScript and PHP cookies? What are the differences between JavaScript and PHP cookies? Sep 02, 2023 pm 12:29 PM

JavaScriptCookies Using JavaScript cookies is the most effective way to remember and track preferences, purchases, commissions and other information. Information needed for a better visitor experience or website statistics. PHPCookieCookies are text files that are stored on client computers and retained for tracking purposes. PHP transparently supports HTTP cookies. How do JavaScript cookies work? Your server sends some data to your visitor's browser in the form of a cookie. Browsers can accept cookies. If present, it will be stored on the visitor's hard drive as a plain text record. Now, when a visitor reaches another page on the site

How to solve the problem that the Springboot2 session timeout setting is invalid How to solve the problem that the Springboot2 session timeout setting is invalid May 22, 2023 pm 01:49 PM

Problem: Today, we encountered a setting timeout problem in our project, and changes to SpringBoot2’s application.properties never took effect. Solution: The server.* properties are used to control the embedded container used by SpringBoot. SpringBoot will create an instance of the servlet container using one of the ServletWebServerFactory instances. These classes use server.* properties to configure the controlled servlet container (tomcat, jetty, etc.). When the application is deployed as a war file to a Tomcat instance, the server.* properties do not apply. They do not apply,

What is the difference between insert ignore, insert and replace in mysql What is the difference between insert ignore, insert and replace in mysql May 29, 2023 pm 04:40 PM

The difference between insertignore, insert and replace instructions already exist or not. Example of insert error. Insertintonames(name,age)values("Xiao Ming", 23); insertignore ignores insertignoreintonames(name, age)values("Xiao Ming", 24); replace Replace and insert replaceintonames(name,age)values("Xiao Ming", 25); table requirements: PrimaryKey, or unique index result: the table id will be automatically incremented. Test code creates table

See all articles