none
Cookies not stored when domain is omitted RRS feed

  • Question

  • I am using a Wampp server inside a corporate network. My pages are using PHP.

    The logging of users is handled by cookies and session variables. It has worked without issues for 10+ years.

    The company is upgrading all PC's to windows 10. Now we can't stay logged in using IE11 Version: 11.829.17134.0 . The cookies are not being retrieved after browser is closed and re-opened.

    My php statement for setting the cookie is:

    setcookie('user', $row['user'], time()+60*60*24*365, '');

    I omitted the domain parameter at the end, as this was the only way to make it work, prior to Windows 10. Now this doesn't work any longer. The server has no domain name and is accessed by the computer name (AF865527:2700).

    I've tried many other names in the domain field for the cookie command, but none works. 

    After logging in, the cookie variables are set and can be see with print_r($_COOKIE), but after closing the browser, and re-opening, the cookie variables are empty. They are not being stored on client computer.

    Is there any way to store cookies with no domain name? It works fine in Chrome and Firefox.

    Thanks,

    Clayton

    Tuesday, July 16, 2019 3:11 PM

All replies

  • Hi Cfelt,

    Please check the IE option is set to clear the data on exit or any group policy set by your administrator can caused this issue.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, July 17, 2019 7:21 AM
    Moderator
  • Yes, that option is unchecked. 

    I should mention that cookies are stored on external sites like normal.

    I have a version of my code running on another server that does have a domain name. I don't have the domain name defined in the setcookie command, but it works as expected (saves cookie).


    Wednesday, July 17, 2019 12:29 PM
  • Hi Cfelt,

    As you said in the original post, that code is creating the cookies and it is accessible but when you close the browser than cookies get deleted.

    It looks like your code is working fine but some IE options or some group policies delete the browsing data.

    So I suggest you to check with your administrator whether there is any policy or settings applied by them to clear the data or not.

    It can help to narrow down the issue.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 18, 2019 5:31 AM
    Moderator