Manoj Kumar Jena
Manoj Kumar Jena

Reputation: 9

session not working in webView in android

I'm new to android developing. I just create an android app for my website using android webview. when i open my website from mobile browser first time it ask login details and once i logged in and close the browser without deleting cookies , then i open the browser again and visit my website it doe

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    WebView mywebview = (WebView) findViewById(R.id.webView1);

    mywebview.setWebViewClient(new WebViewClient());

    mywebview.loadUrl("http://mywebsite.com/");


          }
}

Upvotes: 0

Views: 3754

Answers (1)

intellignt_idiot
intellignt_idiot

Reputation: 1992

You can use this library. It has a method named webView.setCookiesEnabled(true)

I have used this library in one of my projects where I had to keep the user logged in. This library uses advanced/customized webview and has many other useful features that default android webview lacks.

But if you do not want to use this library , and want to proceed with default WebView, then you can use CookieSyncManager that is provided by Android itself. You can read about it here

Upvotes: 1

Related Questions