It is possible, but the mechanism for generating session IDs changed for EE 2.6, so if you want to retain compatibility with 2.5 and under (as I did) you need to add in a quick version_compare
check.
Here's the snippet that I'm using with Missing Link.
$sess_type = $this->EE->config->item('admin_session_type');
$session_id = ($sess_type == 'c') ? '0' : $this->userdata['session_id'];
if (version_compare(APP_VER, '2.6.0', '>=') AND $sess_type == 'cs')
{
$session_id = $this->userdata['fingerprint'];
}
That should give you an accurate $session_id
no matter which EE version or session type is in use.
I'd strongly recommend creating a plugin for this, if you haven't already, as PHP in templates is a Bad Idea.