The ISession interface indeed only has a Set(string key, byte[] value) overload. HttpContext has an ISession Session property.
So everything you want to store in the session has to be converted to a byte array. This can be done in many ways, depending on the type:
byte[] stringBytes = Encoding.UTF8.GetBytes(someString)
byte[] intBytes = BitConverter.GetBytes(someInt);
For complex types, you'll have to use a serializer, for example the BinaryFormatter, as explained in How to convert an object to a byte array in C#.
Luckily there's some extension methods in Microsoft.AspNet.Http that do this for you:
- SetString(this ISession session, string key, string value)
- SetInt32(this ISession session, string key, int value)
And of course their respective Get... counterparts that convert the byte array back to the relevant type.
All you need is a using Microsoft.AspNet.Http; directive in your source in order to be able to use these extension methods.