Closed toni-moreno closed 7 years ago
I'm trying to recover a cookie value with this code.
import { CookieService } from 'angular2-cookie/core'; @Injectable() export class AuthGuard implements CanActivate { constructor(private router: Router,private cookie: CookieService) {} canActivate() { console.log('check canActivate:'); var token: string; console.log(this.cookie.getAll()) token=localStorage.getItem('id_token'); if (token) { console.log('check for cookie: snmpcollector-sess-'+token) var cval; cval = this.cookie.get('snmpcollector-sess-'+token) console.log('TONI cookie'+cval) if (cval) { return true } console.log('Token exist but token ['+ token +'] dont match cookie session'+ cval) return false; }
As you can see in the following image the cookie "snmpcollector-sess-lan exist but this.cookie.get('snmpcollector-sess-lan') returns undefined
Could be this a bug or perhaps I'm doing something wrong?
Check your cookie flags, especially "http-only": https://www.owasp.org/index.php/HttpOnly
Ok.. you are rigth. HttpOnly is set.. Thx !!
@Toub ,thanks a lot!
I'm trying to recover a cookie value with this code.
As you can see in the following image the cookie "snmpcollector-sess-lan exist but this.cookie.get('snmpcollector-sess-lan') returns undefined
Could be this a bug or perhaps I'm doing something wrong?