Please bare in my that I am no web expert and this was my first vue project (just intranet), but this is my problem:
I combined an apache backend (PHP) with vue in combination with axios.
The authentification works with a purely PHP generated form.
This creates a session id on the apache server and I add some session variables storing user id, access rights etc. Then - if successful - php calls the vue app.
Then vue (or to be precise my vue generated JS) calls php scripts which check for my session variables before the return the data to the browser (depending on access rights) etc.
And… it works like a charm!
Problem is: It does not work in my development environment with my apache (XAMPP) running on localhost. And I have no clue why.
Appache runs on port 80
Node js runs on port 8080
I am not sure whether the node server matters at all since it only generates JS code which runs in my browser (as far as I understand correctly).
I debugged my php code with Xdebug and this clearly shows that:
My login form creates a session id, so this works as long as php is concerned.
But as soon as vue (axios) calls any other php code
- the session id is gone
- no new session id is created (which is something I would expect with any call of php code if no session id was found)
So no sessions on localhost with vue/axios?
I read about setting the axios option “withCredentials: true” which did not help at all (and I don’t even have any idea what that option means).
I am just wondering whether my vue-development-server (node js) is involved somehow. Is node js eventuelly calling my php scripts and I have some cross-domain issue?
By the way: I have a second SPA written in vanilla JS with standard AJAX requests and here I don’t have any issues with cookies on my localhost apache server.