News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Josh Adell:
Serializing Data Like a PHP Session
May 02, 2013 @ 09:11:33

In this new post Josh Adell looks at working with PHP sessions and how you can manually encode data to look as if it came from the normal session handling.

If you have ever popped open a PHP session file, or stored session data in a database, you may have noticed that this serialization looks very similar to the serialize function's output, but it is not the same. Recently, I needed to serialize data so that it looked like PHP session data (don't ask why; I highly suggest not doing this if it can be avoided.) It turns out, PHP has a function that encodes data in this format: session_encode.

Unfortunately, this method doesn't take arguments - it just outputs the encoded version of the current session data. So, he came up with his own encode/decode methods that use the PHP session, extract the serialized string and return it.

0 comments voice your opinion now!
serialize data session string unserialize

Link: http://blog.everymansoftware.com/2013/05/serializing-data-like-php-session.html

blog comments powered by Disqus

Similar Posts

Scarletlullaby.com: Refactoring to Rails (MVC) in PHP

DevShed: Developing a Captcha Application with an Image Generator Class with PHP 5

Elated.com: Object-Oriented PHP: Autoloading, Serializing, and Querying Objects

SitePoint PHP Blog: PHP UTF-8 0.1

DevShed: Retrieving Information on Several Objects with Destructors in PHP 5


Community Events





Don't see your event here?
Let us know!


api threedevsandamaybe opinion code refactor language podcast interview release symfony2 introduction series laravel developer framework testing unittest install community list

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework