Capacitor HTTP plugin session cookies

Hi, I’m building a mobile app using Ionic + Vue. I’m using the Capacitor HTTP plugin to handle API requests.

The Auth flow that I’m building works off cookies / sessions. Once I log in, I get a cookie back, creating a session.

The issue i’m having now is that a new cookie is being set with each request, so each session is invalid / each request is invalid. I’ve tried manually setting the cookie, but that hasn’t worked. This is purely a mobile only problem, it works fine in the web view.

A couple of things. First off, using Cookies in a mobile app is not recommended - see Capacitor iOS / Cookie Authentication / capacitor/http - #10 by dallas.

Second, you should only use the Capacitor HTTP plugin when absolutely necessary (Cookies is a reason to or where you run into CORS issues making a request to a 3rd part service where you don’t have control over CORS) as it adds an extra layer of latency within your app. Using the standard web fetch or a library like Axios should be your first choice.

If you absolutely need to use Cookies for auth/sessions, then you’ll need to provide more information and code examples :slight_smile: It kinda sounds like your API/backend is set up incorrectly if it is sending a new cookie with each request. Even if it is, the session ID within that cookie should be the same but sounds like that is not the case.