Is there any way to retrieve session id so other programs could share it for the login? Or is it allowed to share session id among multiple programs for a single user?
Thanks.
No, this isn't allowed. You're allowed to have the user separately log into each app, but you can't share login details between processes like that.
Also, there's no "session id" for libSpotify to expose — this isn't an OAuth app!