The _EPiServer.Session_ NuGet package provides the <string> SessionId for other Optimizely tracking services. A session expires after 30 minutes (by default) if clients have no activity.
You can get the SessionId by invoking EPiServer.Session.ISessionService.GetCurrentSessionId().
The default DefaultSessionService gets and stores the SessionId in the client’s browser cookie (with Max-Age 1800 second (30 minutes)), the cookie, if existed, is renewed on every server request.
You can change cookie duration in SessionOptions, the Duration is the seconds before the cookie expires. The following example (from an Alloy site) shows how to set the duration in class DependencyResolverInitialization: