1354
Views
11
Comments
[InAppBrowser Plugin] How to open a URL with cookies?
inappbrowser-plugin
Mobile icon
Forge asset by OutSystems

Hi All,

I'm trying to open a URL inside mobile app, it works fine but can I pass a cookie/session along with URL?

Reason to do: User is already login into app and if user try to open a URL inside app (InAppBrowser) then user is redirected to login page. I want to pass a session here to avoid this issue.
Please Suggest. 

Thanks in advance.

2020-03-05 14-29-02
José Costa

Hi John,

In Service Studio, in the properties of the Module you can set the property Use Cookies to No. In that case the Session Identifier will go in the URL. 

Does that work for you?

Remember that having access like that to the SessionId can have security issues.

Cheers,

José

2017-08-09 19-45-50
John Snow

Hi José,

Thanks for replying. Solution you have provided is for Web Application. Is there similar features for mobile as well?

Please Suggest. 


2020-03-05 14-29-02
José Costa

Hi John,

My mistake. So, to clear things out:

You have a mobile application (in OutSystems) that uses the InAppBrowser plugin to open a URL from a web application (that is not an OutSystems app). Is that it? Or something else?

Cheers,

José

2017-08-09 19-45-50
John Snow

Hi José,

I have a mobile application (in OutSystems) which is using  InAppBrowser plugin. In mobile Left Menu Drawer, I have a link (Dashboard). This link can be opened by login user only.

Basically, I've a mobile version of a website. User is already Login into App but when I try to open Dashboard Link, I get a website Login page instead of Dashboard.

My main motive here is to pass a sessionID (Available in local storage) as a cookie in URL (InAppBrowser).





2020-03-05 14-29-02
José Costa

Hi John,

But, where/when did the user logged into the website? Because the session from your app is different from the session of the website.

Cheers,

José

2020-03-05 14-29-02
José Costa

Hi John,

Another thing, have you tried to set the values of Clearcache and Clearsessioncache (in the Options input parameter of the Open) to false?

Cheers,

José

UserImage.jpg
Williams Silva
Hi, how did you solve the problem?
2021-01-15 16-58-19
Sherif Diab

Do you have any update about adding cookie, while opening the InAppBrowser?

2022-07-25 08-42-14
Tiago Resende

Hi!

I don't know if it is still a valid question, but I solve it using the JavaScript widget to set the cookie before redirect user to page with InAppBrowser; something like that:


document.cookie = "CookieName=" + $parameters.CookieValue+ "; domain=yourdomain.com.br; path=/";


You need also set clearcache and clearsessioncache Options to False in InAppBrowser, as José Costa said.


2023-08-01 16-31-38
Nagaraju Gaddam

I just came across this issue so thought of answering before I leave as I got a solution for this .

If you are using InAppBrowserEvents plugin, this solution for you.

inAppBrowserRef.executeScript({ code: "document.cookie = 'cookiename=value;path=/';" });


inAppBrowserRef is the inappbrowser open reference and executeScript injects code into inappbrowser website.

Refer cordova documentation for inappbrowser



2023-08-01 16-31-38
Nagaraju Gaddam

If you are just using [InAppBrowser Plugin],  unfortunately no reference has been added so it's not possible to inject any script

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.