Hopefully, this will solve everything in the mobile.
I've taken the solution from Geoff's work, apparently his solution is obtrusive so I took inspiration from his work and apply a better solution to this.
I get all info from the login.html sent by the user server.
Passed the complete information to the login.js of the client.
Disable all auto checking if the user is already logged in.
All auto checks will be done in the login.html of the user server.
I modified also all urls to be sensitive to the protocol for mobile. Since in phonegap, all static files are "file" protocol.
So when it discovered that it is not "http/s", it will assume a relative path.