fixed check for null cookie