setting the right redirect and cookie expiration