You can save a Session in Uniconta. You might want to do this, if you wish to keep a user’s Session, so they do not have to log in again.
In the code beneath, two methods are showed, SaveSession and GetSession.
SaveSession simply saves a Session at a given path as a byte[].
GetSession returns a Session based on a byte[].
If the saved session was logged in, GetSession will return a logged in Session.
public void SaveSession(Session session, string path)
{
var bytes = session.ToArray();
File.WriteAllBytes(path, bytes);
}
public Session GetSession(string path, UnicontaConnection connection)
{
var bytes = File.ReadAllBytes(path);
var session = new Session(connection);
session.FromArray(bytes);
return session;
}