You can use AngularJS service $cookieStore.
But in AngularJS 1.0.7- you cannot set the path or the cookie duration, you will need to implement your own service.
Some additional tips:
-for AngularJS 1.0.7- you need to download the library from here
-you need to inject the service $cookieStore in your controller/service
-you should create a global service that checks/sets/deletes the session cookie
Some starting point example on using a service:
app.service('global', function($cookieStore, $location, $filter) {
var globalService = {};
globalService.user = null;
globalService.isAuth = function (){
if (globalService.user == null) {
globalService.user = $cookieStore.get('user');
}
return (globalService.user != null);
};
globalService.setUser = function(newUser) {
globalService.user = newUser;
if (globalService.user == null) $cookieStore.remove('user');
else $cookieStore.put('user', globalService.user);
};
globalService.getUser = function() {
return globalService.user;
};
return globalService;
});
After your login call setUser to save the user (maybe some token returned by the server) in a cookie.
Then you should send the authentification token data for every request that requires a logged in user.
The token can be a PHP session (if using PHP) and the session can be restored on the server.