Impossible to use cookies in my application


The truth is not that I’m doing wrong, but always get the same error

Error: [$injector:unpr] Unknown provider: $$cookieReaderProvider <- $$cookieReader <- $cookies <- auth <- $cookies

I am using this way all:

<script src="js/angular-cookies.js"></script>

App js :

angular.module('SharedServices', ['ionic','ngCordova','ngMap','ngCookies'])

.run(function($ionicPlatform,$ionicSideMenuDelegate,$rootScope) {
$ionicPlatform.ready(function() {
$rootScope.login = true;
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
if(window.StatusBar) {
document.addEventListener('touchstart', function (event) {
        // workaround for Android
        if ($ionicSideMenuDelegate.isOpenLeft()) {

 angular.module('ionicApp', ['ionic','SharedServices','ionicLazyLoad','ngCordova','ionic.contrib.frostedGlass','ngMap','ngCookies'])
.factory("auth", function($cookies,$cookieStore,$location){
    login : function(username, password)
        //creamos la cookie con el nombre que nos han pasado
        $cookies.username = username,
        $cookies.password = password;
        //mandamos a la home
    logout : function()
        //al hacer logout eliminamos la cookie con $cookieStore.remove
        //mandamos al login
    checkStatus : function()
        //creamos un array con las rutas que queremos controlar
        var rutasPrivadas = ["/home","/dashboard","/login"];
        if(this.in_array($location.path(),rutasPrivadas) && typeof($cookies.username) == "undefined")
        //en el caso de que intente acceder al login y ya haya iniciado sesión lo mandamos a la home
        if(this.in_array("/login",rutasPrivadas) && typeof($cookies.username) != "undefined")
    in_array : function(needle, haystack)
        var key = '';
        for(key in haystack)
            if(haystack[key] == needle)
                return true;
        return false;

Which is not bad for all this, though I still examples is always the same error.


Hey @sioesi,

Could you provide a codepen that contains this error? You could fork this project and add in your cookie code and then post your link here, that’ll help us solve it quicker.

You could use for your cookie file.


Import cookie.min.js and everything was solved, thank you very much friend !. Sorry if I upset but I’m having a problem with the plugin chamber cordova, know something about it?

Greetings and thanks for your help!


Plugin chamber cordova? I don’t know what that is. Here are the docs for cordova plugins. Good luck!


Sorry, write badly. Watch this post here


@sioesi was having the same issue.

I think it has something to do with angular-cookies 1.4 that bower tries to install even when u tell it to use angular version 1.3.13 (the angular version ionic uses)

I downgraded to version 1.3.15 from the CDN that @seanhill recommended and its all working now thanks to this thread :+1: