I want to know... If I am use php setcookie and use angular get the cookie. it is possibile? now I setcookie in php and can see the cookie be creacted in php. but I am use angular to get the cookie console.log will show null value. code:
PHP:
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
header("Content-Type: application/json; charset=UTF-8");
$se='444';
setcookie("TestCookie",$se, time()+3600*24);
$aa=$_COOKIE["TestCookie"];
$value=array('cookie'=>$aa);
$rows=array();
$rows[]=$value;
print_r (json_encode($rows));
angular get cookie:
getco()
{
this.dataService.getcookie(this.cat).subscribe(response =>
{
this.cook = response.map(item =>
{
return new cookies(
item.cookie,
);
});
console.log(this.cook);
});
}
getcookie(id): Observable<cookies[] > {
return this.httpClient.get<cookies[]>(this.baseUrl + '/setcookie.php');
}
When I use console.log(this.cook)it will display null value.