This only works when you actually have a session ID (not the case for Rails' CookieStore, for example):
request.session_options[:id]
# => "142b17ab075e71f2a2e2543c6ae34b94"
Note that it's a bad idea to expose your session ID, so be careful what you use this for.