Create new helper file and write the following function
if ( ! function_exists('flash'))
{
function flash($type, $msg, $bold = '')
{
$ci=& get_instance();
//type:success, info, warning, danger
if($bold != ''){
$bold = '<strong>'.$bold.'!</strong> ';
}
$flash = $ci->session->userdata('flash')?$ci->session->userdata('flash'):array();
$flash[] = '
<div class="alert alert-'.$type.' alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
'.$bold.$msg.'
</div>
';
$ci->session->set_userdata('flash',$flash);
}
}