Ankit Mishra wrote:when you will put -1 as a value that means for cookies you don't want that cookie to be removed even when session expires or when client leaves the browser. In case of session you don't want to invalidate it on the basis of time.
Correct me if i am wrong
This is what the API states for setMaxAge()...
A negative value means that the cookie is not stored persistently and will be deleted when the Web browser exits. A zero value causes the cookie to be deleted.