Often on IRC and the CakePHP google group, I hear people asking how to get values out of the Session or how to find out what is currently in the Session. Generally this is connected to AuthComponent, which is can be complicated component. However, some simple ‘crude’ PHP tactics can make the “whats’s in my session?” question very simple. Grab your layout file and add the following to it just above the
<?php echo $cakeDebug; ?> statement.
- <?php if (Configure::read('debug') > 1) :?>
- <div id="cakeSession" class="cakeSession">
- <h3>Session Info:</h3>
- <?php pr($_SESSION); ?>
- <?php endif; ?>
This simple bit of code should be pretty self evident. And makes it easy to check what’s going on your Session. I like only outputting it at debug > 1 so when I turn down to one both my SQL logs and Session dumps disappear.