Session debugging in CakePHP
Aug 09 2008
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); ?>
- </div>
- <?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.
Search
Categories
Recent Posts
- Using bindModel to get to deep relations
- New home, new sideproject
- Using bitmasks to indicate status
- AclExtras Shell
- Getting a new Oven, Migrating from CakePHP 1.1 to 1.2
- Code Completion for CakePHP in Eclipse
- CakePHP RC3 released and CakePHP 1.1 new release
- Book Review: CakePHP Application Development
- Providing Contextual Form Help with Mootools
- Creating gracefully degrading javascript and enabling progressive enhancement
Comments
Chris Pierce on 12/8/08
Mark,
something i do alot that is a little less “pretty” is
Have Something to say?