set cookie to expire at end of session? asp.net

Viewed 76018

I'm surprised I couldn't find any answers.

How do I set my sessionid in my cookie to expire at the end of session? (when the browser closes or the user has been inactive for a period of time).

The two solutions I found were

(httpcookie).Expires = HttpContext.Current.Session.Timeout

Which gave me a compile error so I don't know if the user checked his code before posting. And the other was to set the expire date to 1 day ago which my gut says is wrong. How do I do this?

4 Answers
Related