Better cookieValue function

Previous version was unable to pick up any cookie but the first one