If to set cookie and better link generator