$cookies need callback once cookie value is set. #6411
Description
Right now if you set $cookies values then call $http immediately, cookie is not updated in the request. if $cookies returns before saving the cookie in the browser then we need callback to execute code that relies on cookie.
$cookies.myName = 'foo'
// request headers are missing myName cookie update from above line
$http.get('/api/getmystar')
To workaround this issue i have to use setTimeout to wait for some time before i can proceed.
It either need to not set the cookie asynchronously or provide a call back function, call back is not possible with $cookies but $cookieStore atleast should solve this issue.
summary
cookie writes are flushed asynchronously, which makes it hard to predict when the cookie will be picked by other browser apis like XMLHttpRequest used by $http