When is a session created

I am trying to figure out how the sessions work, especially how to detect certain cases. So I have a few questions lined up:

  1. Is a Session created for pages only, or are they also created for direct file-access (like an image for example)?
  2. Is a Sessions created for an API call?
  3. Is there a way to detect a 'new Session’ in a custom Route?
  4. There is some explanation of how to construct an Session object, but where should one create/transmit these Sessions?

A session is created when you visit the Panel login page, not when you visit the frontend, unless you use sessions on the frontend, for example for a shopping cart or have a frontend login.

Oke, so how does that work? Does it automatically detects if you set data in the ‘current session’, or do you need to create a session manually in a template (or route)?

And if I do not need to create a session manually, how to know it is a ‘new session’? (or do I just dirty-flag it with a session-data flag?)

There is not much to go on. The following snippet is the only thing I could find for creating a new session.

$session = $kirby->session(['long' => true]);

Is the session automatically assigned as ‘current’? Do I have to create one before I can put data in the
‘session storage’? And where do I need to create a session (if I have to in order to use the ‘session storage’)?

The guide section I linked to has examples and also tells you

Once the first piece of information is stored in the session, the session gets created and a session cookie is transmitted to the visitor’s browser.

$session->get('myplugin.mykey', 'my default value');
$session->set('myplugin.mykey', 'my new value');