Skip to content

Instantly share code, notes, and snippets.

@kosso
Created October 21, 2012 06:41
Show Gist options
  • Save kosso/3926162 to your computer and use it in GitHub Desktop.
Save kosso/3926162 to your computer and use it in GitHub Desktop.
Titanium Android module to clear all cookies from webviews
// Use to clear all cookies from webViews
// - Very useful when logging in users via third party webView login forms.
// Kosso
// October 2012
/*
Usage:
var cookiejar = require('com.hashpan.cookiedroid');
cookiejar.clearCookies();
*/
package com.hashpan.cookiedroid;
import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.titanium.TiApplication;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.app.Activity;
import android.content.Context;
@Kroll.module(name="Cookiedroid", id="com.hashpan.cookiedroid")
public class CookiedroidModule extends KrollModule
{
public CookiedroidModule()
{
super();
}
@Kroll.onAppCreate
public static void onAppCreate(TiApplication app)
{
}
// Methods
@Kroll.method
public void clearCookies()
{
Activity acti = getActivity();
Context context = acti.getBaseContext();
CookieSyncManager.createInstance(context);
CookieManager.getInstance().removeAllCookie();
}
}
@vyatri
Copy link

vyatri commented Aug 2, 2013

Hello. I'm new to this. How can I compile this into titanium module? what should I put on .classpath ? Which SDK version shall I use to compile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment