Exposes the Craft Session ID
To install Session Exposer, follow these steps:
- Download & unzip the file and place the
sessionexposer
directory into yourcraft/plugins
directory - -OR- do a
git clone https://github.com/madebymutual/SessionExposer.git
directly into yourcraft/plugins
folder. You can then update it withgit pull
- -OR- install with Composer via
composer require https://github.com/madebymutual/SessionExposer
- Install plugin in the Craft Control Panel under Settings > Plugins
- The plugin folder should be named
sessionexposer
for Craft to see it. GitHub recently started appending-master
(the branch name) to the name of the folder for zip file downloads.
Session Exposer works on Craft 2.4.x and Craft 2.5.x.
Session Exposer allows you to output a visitor's Session ID on the front-end of a Craft CMS website.
Granted, this is a niche requirement, but can be useful if (for example) you need to detect a session ID on a cached Varnish page to load in an AJAX shopping basket.
This isn't a supported plugin, but feel free to adopt and adapt as required.
No configuration required.
In your template you can expose the session in Twig using {{ craft.sessionExposer.sessionId }}
Brought to you by Mutual