3

I am using Ionic1 with AngularJS.

I asked a question a few days back to fix an issue I had with PHP session variables which will give a deeper look into what I have done in my code:

PHP $_SESSION variables not working in ionic/angularjs application

My Issue:

I was developing it on Android and now I am developing it for iOS. What I have done is ported my files over to a mac and created a new platform (iOS) via ionic/cordova commands for my app. Both the android and iOS version of my app uses the same code and points to the same set of server/PHP files.

On the android version, it seems to keep the PHPSESSID the same throughout, from logging in and going into different pages with HTTP requests but on the iPhone simulator on xCode it doesn't seem to. The PHPSESSID changes on each HTTP request.

An example:

In my login.js I do a $_POST request to validate login details. If correct, move $state to menu.js. In this file, I do 3 separate $_GET requests to get data to be used in the app. When I inspect this when using an android emulator/browser it displays the set-cookie: PHPSESSID and it is the same for all requests while on the iOS it has a different PHPSESSID per request.

I've looked through a few stackoverflow questions:

PHP cookie is not staying set in uiwebview

Keep losing php session cookie in UIWebView

Can I set the cookies to be used by a WKWebView?

But I don't quite understand the answers and I'm not even sure if the answer applies to mine.

How come the iOS emulator doesn't work even though it is using the same files as the android platform?

J.Do
  • 303
  • 6
  • 26
  • Do you manually set the cookie lifetime? That at least retains the session cookie between home screen 'installed' and in-browser versions of your web app, it might be of use. Check my answer to this question if you don't know how. https://stackoverflow.com/questions/9998900/maintain-php-session-in-web-app-on-iphone – Wilbo Baggins Feb 09 '19 at 17:32
  • @WilboBaggins I don't manually set the cookie lifetime no. I assume it automatically sets one up. But I have just tried your fix and it still does not work. But I wouldn't think I would need to do this as it already works fine for Android? – J.Do Feb 11 '19 at 09:53
  • Did you get any fix for this?? – Anas Sep 03 '20 at 06:46

0 Answers0