don't store private public-share-key in session

proposed solution for #12405 

cc @DeepDiver1975 @LukasReschke @MorrisJobke what do you think?
Add the session close  to the top of the file then. Otherwise it will be closed never.