<p>Old post, I know, but we've recently published a plugin to achieve this for a similar problem we were facing.</p>

<p><a href="https://github.com/madebymutual/SessionExposer" rel="nofollow noreferrer">SessionExposer plugin</a> can help you achieve this. To get the Session ID in the template you use</p>

<pre><code>{{ craft.sessionExposer.sessionId }}
</code></pre>

CC BY-SA 4.0
2022-11-29T17:06:27.377Z
Any idea if this plugin is still available somewhere? Need to do this on a legacy Craft2 site.
erwinheiser
CC BY-SA 4.0
2022-11-30T08:05:21.977Z
@erwinheiser yes I've restored it at https://github.com/madebymutual/SessionExposer now, please note it's archived and entirelty unsupported. But hopefully it works for you
Mutual
CC BY-SA 4.0
2022-12-01T10:05:29.247Z
That's awesome, many many thanks! I'll definitely check it out.
erwinheiser
CC BY-SA 4.0
2022-12-01T17:56:15.623Z
works as advertised, thanks again!
erwinheiser
CC BY-SA 3.0
2017-03-11T15:12:49.027Z
2017-03-11T15:12:49.027Z
Mutual
<p>I assume you're referring to the PHP session ID (wrapped by <a href="http://buildwithcraft.com/classreference/services/HttpSessionService" rel="nofollow">HttpSessionService</a>)?</p>

<p>If so, the answer is no - Craft doesn't expose that to the templates.  You'd have to write a plugin that did.</p>

CC BY-SA 3.0
2015-05-28T14:34:54.717Z
Yes, I has hoping to grab the session to send along for a unique identifier for some tracking purposes. Looked at the request.getCookie() also but no luck.
Derrick Grigg
CC BY-SA 3.0
2015-05-27T22:07:50.607Z
2015-05-27T22:07:50.607Z
Brad Bell
<p>Is there a way to get the session id from craft.session in a twig template without needing to create a new filter?</p>

<session>
Getting session Id in twig template
# Getting session Id in twig template

(Asked by: username_0 on 2015-05-27)

Is there a way to get the session id from craft.session in a twig template without needing to create a new filter?

**Tags:** session

---

## 2 answers

### Answer by username_1 on 2017-03-11. Score: 3

Old post, I know, but we've recently published a plugin to achieve this for a similar problem we were facing.
SessionExposer plugin can help you achieve this. To get the Session ID in the template you use
{{ craft.sessionExposer.sessionId }}

> **Comments:**
> **username_2**: Any idea if this plugin is still available somewhere? Need to do this on a legacy Craft2 site.  
> **username_1**: @erwinheiser yes I've restored it at https://github.com/madebymutual/SessionExposer now, please note it's archived and entirelty unsupported. But hopefully it works for you  
> **username_2**: That's awesome, many many thanks! I'll definitely check it out.  
> **username_2**: works as advertised, thanks again!  

---

### Answer by username_3 on 2015-05-27. Score: 1

I assume you're referring to the PHP session ID (wrapped by [HttpSessionService](http://buildwithcraft.com/classreference/services/HttpSessionService))?

If so, the answer is no - Craft doesn't expose that to the templates. You'd have to write a plugin that did.

> **Comments:**
> **username_0**: Yes, I has hoping to grab the session to send along for a unique identifier for some tracking purposes. Looked at the request.getCookie() also but no luck.  

---

