Add session support (fixes #611)