Codeigniter & PHP check if session exist
Check for a valid session id:
$sid = session_id();
For example:
$sid = session_id();if($sid) { echo "Session exists!";} else { session_start();}
The first point is "Don't fight the framework" when your framework has some functions than use it. Normally in the Framework classes are functions to prevent injections.
Here is a Post when tells you how to check the cookie:
And for the session
I think you can simply check by doing something like:
if(isset($_SESSION)){ // tells php session is initiated}if(isset($_COOKIE)){}