Software Archive
Read-only legacy content
17061 Discussions

Retrieving a remote page BEFORE local app starts

Dario_C_
Beginner
473 Views

Don't ask me why, but I'm doing a remote login system for a CMS that runs on a server.

My app consists in just an html form with the username and password fields, then that form does a post to the login pag eon the remote CMS and let the cms do the rest.

The main problem is that the CMS login system uses session cookies, it sets them the first time the remote login page is visited. My workflow now goeas as follows :

The user opens the app, the local login form is shown. Th users confirms the form, and it is redirected to the remote login page, who doesn't find any session cookie so fails the login and creates the session cookie. If the user press the back button and goes back to the local form and re-submits it is now able to do the login cause the session cookie is now present.

Is there a way with XDK to visit a remote page, so the cookie is stored, then go back to the local login form automatically without the user noticing it?  Actually I have no access to the remote source code or server, so I cannot modify it.

Thanks a lot.

Dario

0 Kudos
6 Replies
Barry_Johnson
New Contributor I
473 Views

Based on your description, it seems you are going to the remote server within your app's main webview. In that case, could you just make an XHR call to the server in the background when you launch? I believe if you set "withCredentials" true the XHR calls should properly maintain cookies.

0 Kudos
Dario_C_
Beginner
473 Views

Unfortunately the remote server doesnt have 'Access-Control-Allow-Origin' header, so I cannot make CORS requests...or maybe I'm missing something?  Anyway, thanks for the previous answer  :D

0 Kudos
Barry_Johnson
New Contributor I
473 Views

Does loading a publicly-accessible image from the server (like its favicon or any image on its standard login page) send back a response with set-cookie headers (i.e. does it set up a session)? If so, you could see if creating a new Image() in JS and setting its source would work - or for that matter embedding the image on your page but hiding it in some form or fashion (offscreen, z-axis, etc), I don't know if you could suppress it via styling it with display:none, as I am not sure the container would attempt to load the image.

Not sure what would happen if you tried loading the remote login page via an offscreen iframe, but that might be something to try as well.

0 Kudos
Dario_C_
Beginner
473 Views

The image failed the test :D  and the iframe too.

I was happy with XDK, but I think the only way is to move to a development that gives me the ability to manipulate the web control url via external non javasript code like this :

webControl.load(remoteurl);

ait for loading done then...

webControl.load(localurl);

 

 

0 Kudos
Michael_O_
Beginner
473 Views

Dear Dario,

The best thing is to gain access to the back end for easy access.

 

0 Kudos
Dario_C_
Beginner
473 Views

At last I managed to get in contact with one of the backend developers who gave me the ability to put a redirect on the server without the need to access the original sources.  This work resulted in an headache...

Thanks everyone for the help, this looks like a pleasant community.

0 Kudos
Reply