Q:

Trying to get session ID from cookie in Codeigniter but...

I am trying to retrieve the session id from $_REQUEST/$_COOKIE in Codeigniter.  The problem is it returns the following and I don't know how to access it:
a:4:{s:10:"session_id";s:32:"f42269d0f23d0310b0274a580c90627e";s:10:"ip_address";s:13:"128.128.128.128";s:10:"user_agent";s:50:"Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/2010010";s:13:"last_activity";i:1311979074;}ffcb685c182ffbbb1affd1ee49a558df

What in the world is that and how to I pull the session id(f42269d0f23d0310b0274a580c90627e)?

A:

it's php serialize() output, use http://www.php.net/manual/en/function.unserialize.php to convert it back to PHP data type

A:

Looks like you're accessing session data incorrectly. The serialized data you are seeing is stored in the database or if you're not using database, in the session cookie. To get the session ID you should be using the Codeigniter session "userdata".
So to get the session ID you would go: $this->session->userdata('session_id');
Remember that Codeigniter sessions aren't native PHP sessions, so you sort of have to use the session class function to get the values correctly. My understanding of the unserialize() function is that it is pretty expensive in performance and you probably don't want that added overhead of using it unnecessarily.

