Cookie Failure on Mobile Devices

Posted at 7:40:45 PM in Web (12)

After several days of trying to work around an issue with identifying mobile devices through storing cookies, I finally figured out what caused the problem.

I'm writing an app to be used on various devices that I decided to compartmentalize by company. Doing so required that when the application is opened, it be aware of the company the user was logging into. If it was in a pick list, then people would know which companies to try to hack or try to guess which companies or how many companies are using the app. So, this all needed to be transparent to the public. Of course, the companies using the app would have to know how to set it up. That's proprietary information. However, once sent, it would have to be present each time that device or browser on that device connected. Cookies should work for that and it was for computer browsers. I tested Brave and Chrome. I believe it would have responded the same way for Edge but I didn't test it there. But on mobile browsers, the very same browsers that worked on computers, wouldn't work. It kept insisting that I reinitialize the company info.

Neither browser allows access to see the cookies. In fact, in the Brave browser, it was very difficult to see them. Chrome was more forthcoming. In Brave, I had to use the developer inspection tool, then on the application tab, Cookies are displayed and are manageable on the left side. Every search I used to find out why the mobile browsers did not save cookies only revealed information on how to clear or delete cookies. None of them explained how to keep them.

Finally, in the Brave browser on the computer where I could see the cookies, I decided to see what showed in the expiration column. They all said "Session". I believed they expired after 30 days. I have no idea where I got that idea. But it turns out that session means that they expire when the browser session is closed. Computer browsers don't pay attention to that. Once I set an expiration date on the cookie, it remained in the mobile browser as well. The mobile browser apparently follows the expiration, computer browsers don't. I'm sure there's a setting that affects that and maybe this is just common knowledge, but I couldn't find anything on it in my research.

Written by Leonard Rogers on Friday, December 23, 2022 | Comments (0)