Added cookie null check