I have custom php script that is called with ajax. It must be stand-alone script to save spent resources because it is called 1-3 times per each page load. Init Magento for each ajax call would cause server overload.
In that stand-alone script I use session so I start it with session_start().
Problem: Some customers (in rare cases) reported that it removes products from cart and starts new session when ajax call to this script is loaded. I could not reproduce the problem on my side, but I suspect this is the problem: enter image description here
As you can see in the image, it will create another PHPSESSID cookie. I read that modern browsers should not care about the leading dot, but here it will duplicate cookie.
Does anybody have any hint why this happens?
3 Answers 3
I encountered the same problem. I have a Magento site running on site.com and a Symfony application running on app.site.com. Magento was setting the cookie domain as ".site.com" which was conflicting with the cookie (PHPSESSID) that was needed by app.site.com.
The solution I found was to set the "session.name" value directly in the Magento virtual host (I'm using Nginx)
fastcgi_param PHP_VALUE "session.name = magento";
I resolved the problem by renaming session inside custom script:
session_name('UNIQUE_NAME');. This works because I don't need to share session between Magento and custom script.
I have posted the solution on my own question. Magento 2: User cant logged in into to account page, no error showing!
I got the solution for it, i installed the php chat plugin on the server and embed into magento 2 website. the issue was coming from the cookies that both of them was generated on the same url. when you look at the PHPSSID into the inspect element , it will show duplicate PHPSSID and one of them was conflicted with origenal one. Solution - i have created the subdomian and copy the chat code into the subdomain. that completely solve my problem.