April 14, 2013 asvignesh
Highlight your php code in your website or in your blog post Instead of using external tools or third party code to highlight the syntax of php code in your website you can use the inbuilt function of php highlight_string or highlight_file Highlight_string is the function to highlight the php syntax of the block of code Here is the example for the highlight_string <?php $code = ‘ <?php //array with files to allow $allowed = array(“index.php”, “menu.php”, “about.php”); // get the filename $file = $_GET[file]; if(file_Exists($file)){ if(in_array($file, $allowed)){ // check if it is part of the allowed list highlight_file($file); //highlight…
April 7, 2013 asvignesh
Session often breaks in codeigniter ??? Here is the fix ! I developed e-commerce website using php codeigniter and it is using database to store session values. But the session is lost if it has more data in it I have spent some days checking about it and changed the third party session library , it has lots of limitations again i switched back to codeigniter default session library and trying to fix the issue finally i found out the issue in it. It was failing to unserialize the session data stored in the user_data field in ci_session table So…
April 7, 2013 asvignesh
Best practises in checking codeigniter sessions There are many practices in checking the session conditions for whether the user is logged in or not Usually we check in the codeigniter controllers function my_function() { $user = $this->session->userdata(‘user_id’); if (!isset($user)) { $logged_in = false; } else { $logged_in = true; } } This 4-8 lines of code you need to check in every controller , So you can create a codeigniter library and call the library function in every controller , It is easy to code and also in modifying the code  Create a my_library.php file in application/libraries Copy the following…