Code Monkey home page Code Monkey logo

cordova-cookie-master's Introduction

IMPORTANT: This plugin is no longer maintained. It is possible that some functionality may be deprecated in newer target SDKs.

Cookie Master

As you may already know, WebViews on Android and iOS platforms do not support regular use of document.cookie for managing the cookies in your app. This plugin allows you to get and set cookie values from your WebView through a simple interface.

Supported Platforms

  • Android
  • iOS

Installing

Install with Cordova CLI

$ cordova plugin add https://github.com/kristianhristov/cordova-cookie-master.git

Usage

Get cookie value

cookieMaster.getCookieValue('http://<some host>:<some port>', '<cookie name>', function(data) {
  console.log(data.cookieValue);
}, function(error) {
  if (error) {
    console.log('error: ' + error);
  }
});

Set cookie value

cookieMaster.setCookieValue('http://<some host>:<some port>', '<cookie name>', '<cookie value>',
    function() {
        console.log('A cookie has been set');
    },
    function(error) {
        console.log('Error setting cookie: '+error);
    });

The cookie value should be formatted just like a regular document.cookie value.

Clear all cookies

cookieMaster.clear(
    function() {
    console.log('Cookies have been cleared');
    },
    function() {
        console.log('Cookies could not be cleared');
    });

Limitations

  • This version has been tested on Android 4.4 ~ 5.1 devices, iOS 7.1 ~ 9 devices. Experience may vary for different OS versions.

License

This plugin is distributed under the MIT License.

Thanks to

This plugin was inspired by the great work on the CookieMonster plugin by @barrettc

cordova-cookie-master's People

Contributors

davidofwatkins avatar dougnukem avatar kristianhristov avatar stephenlacy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cordova-cookie-master's Issues

Cookies are not getting set when using WKWebview Kit iOS ionic

Cookies are not getting set after implementation WKWebview kit in IOS

Please help!

Ionic info
Ionic:

ionic (Ionic CLI) : 4.6.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.1

Cordova:

cordova (Cordova CLI) : 8.1.2 ([email protected])
Cordova Platforms : ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.5.1, (and 23 other plugins)

System:

NodeJS : v10.15.3 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS Mojave
Xcode : Xcode 10.2 Build version 10E125

Session cordova

Hello,
Session remains active after the phone closed with cordova

HTTPS support

Is this plugin expected to work for HTTPS endpoints? My preliminary testing seems to show it doesn't work...

How to use

After running

cordova plugin add https://github.com/kristianhristov/cordova-cookie-master.git

I could not use window.cookieMaster.setCookieValue('http://example.com', 'AUTH_TOKEN')

Do I miss something?

Build Errors with android-25 and cordova android [email protected]

Given the following targeted SDK and Platform:

cordova platform add [email protected]
Adding android project...
Creating Cordova project for the Android platform:
	Path: platforms/android
	Activity: MainActivity
	Android target: android-25
Subproject Path: CordovaLib

Here's the Build Errors

:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
<RootFolder>/platforms/android/src/com/cordova/plugins/cookiemaster/CookieMaster.java:91: error: package Build does not exist
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
                     ^
<RootFolder>/platforms/android/src/com/cordova/plugins/cookiemaster/CookieMaster.java:91: error: package Build does not exist
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
                                              ^
<RootFolder>/platforms/android/src/com/cordova/plugins/cookiemaster/CookieMaster.java:92: error: method removeAllCookies in class CookieManager cannot be applied to given types;
                            cookieManager.removeAllCookies();
                                         ^
  required: ValueCallback<Boolean>
  found: no arguments
  reason: actual and formal argument lists differ in length

Here's the solution that worked:

+++ fixes/CookieMaster.java	2017-01-27 08:00:55.000000000 -0800
@@ -12,6 +12,7 @@
 import java.net.HttpCookie;

 import android.webkit.CookieManager;
+import android.os.Build;

 public class CookieMaster extends CordovaPlugin {

@@ -89,8 +90,8 @@
             CookieManager cookieManager = CookieManager.getInstance();

             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
-			    cookieManager.removeAllCookies();
-			    cookieManager.flush();
+			    cookieManager.removeAllCookies(null);
+			    cookieManager.flush();
 			} else
 			{
 			    cookieManager.removeAllCookie();

Missing command error when setting cookie

When I do

    cookieMaster.setCookieValue('http://example.com>', 'cookie', 'value',
      function(data) {
          console.log('A cookie has been set');
      },
      function(error) {
          console.log('Error setting cookie: '+error);
      });
    })

I get this error instead of cookie being set.

Api v. 22, android 5.1.0

phonegap build

Found that the ios build is okay for phonegap build but not for android.
Any directory named wrongly?

Error - Plugin error (you probably need to remove plugin files from your app): Error during processing of action! Attempting to revert... Failed to install 'com.cordova.plugins.cookiemaster':Error: Uh oh! "/tmp/gimlet/5755/1630540/www_android/project/cordova/plugins/com.cordova.plugins.cookiemaster/src/android/com/cordova/plugins/cookiemaster/CookieMaster.java" not found! at Object.module.exports.common.copyFile (/home/ec2-user/.npm/lib/node_modules/plugman-npm/node_modules/cordova-lib/src/plugman/platforms/common.js:38:40) at Object.module.exports.common.copyNewFile (/home/ec2-user/.npm/lib/node_modules/plugman-npm/node_modules/cordova-lib/src/plugman/platforms/common.js:69:16) at Object.module.exports.source-file.install (/home/ec2-user/.npm/lib/node_modules/plugman-npm/node_modules/cordova-lib/src/plugman/platforms/android.js:78:20) at installWrapper (/home/ec2-user/.npm/lib/node_modules/plugman-npm/node_modules/cordova-lib/src/platforms/platforms.js:76:32) at Object.ActionStack.process (/home/ec2-user/.npm/lib/node_modules/plugman-npm/node_modules/cordova-lib/src/plugman/util/action-stack.js:68:25) at handleInstall (/home/ec2-user/.npm/lib/node_modules/plugman-npm/node_modules/cordova-lib/src/plugman/install.js:543:20) at /home/ec2-user/.npm/lib/node_modules/plugman-npm/node_modules/cordova-lib/src/plugman/install.js:340:24 at _fulfilled (/home/ec2-user/.npm/lib/node_modules/plugman-npm/node_modules/q/q.js:787:54) at self.promiseDispatch.done (/home/ec2-user/.npm/lib/node_modules/plugman-npm/node_modules/q/q.js:816:30) at Promise.promise.promiseDispatch (/home/ec2-user/.npm/lib/node_modules/plugman-npm/node_modules/q/q.js:749:13) Uh oh! "/tmp/gimlet/5755/1630540/www_android/project/cordova/plugins/com.cordova.plugins.cookiemaster/src/android/com/cordova/plugins/cookiemaster/CookieMaster.java" not found! - You can fix this here

build failed on android sdk 23

:compileDebugJavaWithJavacC:\...\myapp\platforms\android\src\com\cordova\plugins\cookiemaster\CookieMaster.java:12: error: package org.apache.http.cookie does not exist
import org.apache.http.cookie.Cookie;
                             ^
 FAILED
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Fix
http://stackoverflow.com/questions/32153318/httpclient-wont-import-in-android-studio

HttpClient was deprecated in API Level 22 and removed in API Level 23. You can still use it in API Level 23 and onwards if you must, however it is best to move to supported methods to handle HTTP. So, if you're compiling with 23, add this in your build.gradle:
android {
useLibrary 'org.apache.http.legacy'
}

and

HttpClient is not supported any more in sdk 23. You have to use URLConnection or downgrade to sdk 22 (compile 'com.android.support:appcompat-v7:22.2.0')

If you need sdk 23, add this to your gradle:

android {
useLibrary 'org.apache.http.legacy'
}
You also may try to download and include HttpClient jar directly into your project or use OkHttp instead

... which indeed works!

Missing command error when getting cookie

cookieMaster.getCookieValue('http://phmavclmdb1.infor.com:21007/REST', 'IRCVMLKHOJUWILKWGI5DUOR2', function (data) {
console.log(data.cookieValue);
}, function (error) {
if (error) {
console.log('error: ' + error);
}
});
also tried
cookieMaster.getCookieValue('http://phmavclmdb1.infor.com:21007', 'IRCVMLKHOJUWILKWGI5DUOR2', function (data) {
console.log(data.cookieValue);
}, function (error) {
if (error) {
console.log('error: ' + error);
}
});

But I got Missing command error. I hope you could help me. Im using Windows 10.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.