I am trying to develop 2 pages:
Page 1: Normal Login Page login.html Page 2: Home Page home.html
I am using AngularJS to code the scripts in these pages.
I have to transfer some data between these two pages. So i decided to use cookies (I tried to use Services but i didn't know how to write the same service for 2 separate files).
In the Login page i saved the cookies as follow :
var resultObj = {'loginid',result};
$cookies.dotobject = resultObj;
window.location = 'Home.html';
I checked that this cookie is saved correctly (Console.log(resultObj))
However when i open the home page i try to read this cookie using:
var result = $cookies.dotobject;
console.log(result) //To check if it worked
But it didn't, i got undefined.
My question is can I use $cookies in this case ? And why does it disappear ?
If cookies are not useful in this case how to use a service between 2 different pages containing 2 different controllers ?
Excuse me if this questions aren't from a good quality since i am still learning these concepts.
EDIT
I tried to write in the same document :
console.log(result);
$cookies.put('loginid',result);
var loginida = $cookies.get('loginid');
console.log(loginida);
But the $cookies.get does not work ; It gives also undefined . Any ideas ?