Safe way to get Anonymous Session ids

I'm using rapido.plone to get the Session id.
What's the difference between A:

return context.request.SESSION.id

(saw the example here: https://stackoverflow.com/questions/1034252/how-do-you-get-and-set-cookies-in-zope-and-plone)

and B.

portal = context.api.portal.get()
sdm = portal.session_data_manager
return sdm.getBrowserIdManager().getBrowserId(create=True)

(saw the example here: https://stackoverflow.com/a/35838677 followed by a note to suggest that this is bad for performance)

More importantly, since B appears to be a bad idea is A safe? (trying to figure it out now).

1 Like