I need some clarifications in cookie. I am setting cookie for the username. If the user visits the page for the 2nd time control redirects to another page without asking the username again.

For ex: User visits 1st time www.sample.com where we accespts the username and page goes to sample1.com. After accepting ths username in the same window without closing it, if i again gives www.sample.com control goes to sample1.com with the username that is accessed from the cookie.

But if i close the window and again opens the page www.sample.com page is redirected to sample1.com but it displays t=2 instead of accessing the username, after this if i clear the cookie and agai gives the name it accepts.

Is this the correct way of working or it does contains error.