How to access Cookies in Chrome after i close my Browser - php

I am facing one issue when I close my chrome browser and it will not show my cookies information in where I print information using $_COOKIE
I set Cookies for 30 days here is the code which is used to set cookies:
setcookie("cookie[".$_product->getSku()."]","".$_product->getSku()."",time()+2592000,'/','new.domain.com',true);
my site is secure so I set true as last parameter
it shows correct cookies information if I am not closing my browser but when O close my browser and come again it will not show the information which I set in cookies.
But when I show cookies information it will show me the cookies which were set earlier.
i also set setting of chrome to unchecked the option so when i close browser it will not delete my cookies too from chrome browser setting.
cookies is working correctly in FireFox eventhough if i close browser, but i can't get an idea what is the issue comes in chrome so if anybody is there which has faced this type of issue then please let me know what i can do to solve this issue
note: i also set expire time of cookies

Odd that it works in Firefox. I assume your Chrome installation is up to date!? Have you tried using setcookie() whist omitting the path and domain parameters to see if that alerts the behaviour in Chrome?

Related

Loss of cookies in Chrome

I send the user to the bank site for online payment.
After the user returned from the bank site to my site, the site cookies were completely removed.
This problem has occurred to me recently and is not a problem in Firefox browser.
What is the cause of this problem?
My site is with PrestaShop
If this issue only persist in Chrome, i am guessing it could be an issue with Chrome disabling "SameSite" cookies as default value.
Allow cross-origin cookies:
go to /yourstore/.htaccess and add on top of this file the code SameSite=None
Make sure to clear your brower cookies
More details about SameSite cookies can be found here

PHP Session resumes after browser close with new PHPSESSID in Firefox

In Firefox (and Microsoft Edge) I'm seeing something that I assume is impossible.
I log into my website and get a PHPSESSID of 6a47272fa6d7b4de2292966bf77ddb51
I close Firefox
I reopen Firefox and I can see in the options that my website has no cookies set (as I expect)
I visit website again without Logging in and my session is still active (I'm still logged in) but my PHPSESSID is now 7d4117307c86faa7ea9dc7afe6b4b720
I'm not looking for a fix. I just want to know how this behavior is possible. How could PHP know which Session to resume if Firefox is not sending a PHPSESSID after the browser closes?
I don't see this happen in Chrome (the user needs to log in again as you would expect), but I do see it happen in Microsoft Edge.
After paying very close attention to my network tab in Firefox. I discovered that neither PHP nor Firefox remembered that I was logged in.
Rather my website was redirecting me to Google Sign In and Google Sign In has non session cookies that remembered I was logged in. So it quickly redirected me back to my website creating a new logged in session for the same user.
It was happening so fast it I could not tell that I was being redirected to Google until I watched the network tab.
Thanks Axalix for the suggestion.

Iframe not reading cookies in IE while p3p header has been set

I have a php site with an iframe that leads to a .net site, if the user leaves the website we send the user a email that gives them a link that sets a session and a cookie that will allow the user to return to the site with all their details still filled out, we do this by sending the user to a link that leads to a page that is on the .net sites domain and sets a cookie and a session variable and then redirects to the php page that has the .net IFrame
In Chrome and firefox we have no problems what so ever but with IE the cookie and session are not being read, I have read that the now unused p3p policy is still enforced by IE when cookies are used with iframes so I have set content headers through IIS (and tried to set different cp values as well) but this has changed nothing
does anyone have any idea what I could try to get this working with IE? Thanks
Update
OK so the p3p headers on the domain setting the cookie (and the domain receiving the cookie as well) is p3p CP="NID DSP ALL COR" and the set cookie header is Set-Cookie cookiename=CustId=249674; expires=Wed, 23-Oct-2013 08:29:03 GMT; path=/ it also seems to pick up the cookie on the cookies section of the network tab when on the php page with the IFrame,but the request that the iframe makes get no cookies
You should start by reading this article, then you should share the HTTP response headers that contain both the Set-Cookie and the P3P header. You can collect these headers with Fiddler or the F12 Developer Tools' Network tab.
It Seems IE was having problems with the page contained in the Iframe only being part of a virtual directory in IIS and not actually in the website, when I removed the virtual directory and placed the files within the actual website all IE Problems disappeared, very odd but it works now

How browser delete session or delete history works?

Let a user using Mozilla browser , On three tabs he login to his yahoo account ,gmail and hotmail.
Now if we Clear Recent History , all three session will be cleared.
But at the same time if there is another session in any another browser it will not be cleared.
So What i am trying to ask here is , the cookies and session related details ,browser cache will be in the local computer and it will be cleared on clearing history.
But is it browser specific?
The cookie and all will have any browser specific id , how it will differentiate that now clear the IE history or clear chrome history.
You can in fact use two different accounts on two different browsers at the same time. The browser history/cookies etc are specific to the browser in question.
There isn't a "standard" where browser save their settings, each do it as they file. MSIE might use the Windows Registry while Firefox might use a local database file.
For the server to keep track of a client session a session id is sent to the client. Which the client uses in each request to the server.
On the local computer each browser has it's own way of saving the cookie files. So when you clear the cookies in Firefox, then the cookies saved by Firefox will be deleted. Same thing with Chrome, IE, Safari etc.
They could even be using a own way of serializing the cookies for all that I know.

Internet Explorer 8 doesn't pass session cookie for ajax request

I have simple php application, it works on all browsers except on IE8 beta 2, problem occurs when I try to update table field using Ajax call (jQuery post method). Using IE8 debugger I figure out that IE8 doesn't send session cookie so php scripts redirects to login page instead of executing requested action.
What can I do to make this work.
Edit:
I haven't mention that i was using Code Igniter so i have solved this problem by replacing Code Igniter default session implementation with native one. Code igniter default session implementation uses cookie to store all data.
Yesterday I had similar problem and found the solution. I hope this will help someone else also.
Problem: Suppose there's a website www.somewebsite.com and IFRAME inside it whcih loads php file from my server, www.myserver.com/welcome.php. Website was loading successfully as well as my welcome page and it showed something like "Hello Bob", so it successfully found user and logged him in.
Afterwards my JavaScript was making AJAX calls to another PHP file, and response was kind of in "not authorized" state, so SESSION data was completely missing. After page refresh, everything was working correctly. And this was happening only under IE8!
I thought that problem was with sending session cookies to the server, but when I installed Fiddler, I found that IE8 was sending cookies as well as PHPSESSID correctly, but server was kind of unable to detect correct SESSION object. Another strange thing was that 2nd time server sent following header:
P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
but first time no. After adding that header manually in PHP script, everything worked like a charm!
Then, when I googled that "p3p abracadabra", I found following web site:
http://adamyoung.net/IE-Blocking-iFrame-Cookies
Conclusion: Make sure that you're sending the header on every page that sets a cookie.
And this is not only related to IE8 + PHP combination, same problem happens in case of IE8 + ASP.NET, IE8 + JSP, etc.
I don't have IE8 myself, but your cookie might be blocked by Internet Explorer's strange security policies. A possible workaround can be to employ P3P (which is also the method for getting cookies working inside an IFRAME).
Generating the right P3P policy can be a bit of work, but you should be able to find the information you need at http://www.p3ptoolbox.org/
I had the same problem in IE8 RC1:
1)a user goes to the login page and a blank session cookie is set
2)The user logs in and a validated session cookie is set and javascript opens a new window and closes the current window.
3)The new window is opened and contains a blank session cookie.
4)The user is redirected to the login page
I changed step 1 so that the blank cookie was not set - I only send the session cookie if its been validated. This fixed the problem for me.
I am having trouble getting IE8 to use SSL Certificates (PK12) files as a means of authorization. If I want to protect a directory and force a matching web certificate to be present in the browser before granting access. It works fine with IE7 and all versions of Mozilla - just not IE8. It has rendered my wife's dictation system useless. One other thing I noticed is that when it sets the PHPSESSID cookie, it list the domain as .net and not mydomain.net.
As a workaround, you can embed the SessionID as a parameter on the uri.
See passing session id in the php manual.

Categories