Samy Massoud
Samy Massoud

Reputation: 4385

CodeIgniter set_flashdata method echo content to browser

This is very strange issue.
I have a running website which has no problem with me or any one i know.
but one of my clients told me that he have a strange codes so i asked him for a screen shot and here it's

error with set_flashdata

The code where this happen

$this->session->set_flashdata(array('success_msg' =>'Some message'));
redirect(base_url());

Redirect didn't happen and user get a content of his local cookie into the browser like what's in image , he uses Firefox and windows as os .

A gain I can't re produce this issue and he told me that happen to him every time he visit this page !

Any idea ?

Upvotes: 0

Views: 555

Answers (2)

saurabh kamble
saurabh kamble

Reputation: 1549

Set the Session Flash Data as above

$this->session->set_flashdata('updateprofile','Your Profile has been Updated');

to print this data in the view use

<?php if($this->session->flashdata('updateprofile')): echo $this->session->flashdata('updateprofile'); endif;?>

Upvotes: 1

Alessandro Minoccheri
Alessandro Minoccheri

Reputation: 35973

you have a syntax error: miss )
Isn't necessary to use array in this case
try to change this:

$this->session->set_flashdata(array('success_msg' =>'Some message');

to this

$this->session->set_flashdata('success_msg','Some message');

make sure error reporting is enabled, or try placing the following at the top of your index.php.

error_reporting(E_ALL | E_WARNING | E_NOTICE);
ini_set('display_errors', TRUE);

Upvotes: 0

Related Questions