Added auth cookie logic