Set timeout and cookie lifetime depending on values provided in the new API

Change-Id: Id2e3dd1ea3f80ee5277237e895e8374bdfce4bd0