Rakesh
Rakesh

Reputation: 11

Codeigniter flashdata issue

Codeigniter flash data issue I am not getting session flashdata value. I checked the session there flash data is created as old. Why this happens and how can i correct the issue.

my sessiona:

3:{s:9:"user_data";s:0:"";s:11:"cp";s:5:"l";s:14:"flash:old:fvalue";s:32:"41f666‌​04a0bec1c089d84023d3708d1d";}. 

here flash data is marked as old. i created flash data in view this is my code $this->session->set_flashdata('fvalue', '41f66604a0bec1c089d84023d3708d1d');

Upvotes: 0

Views: 936

Answers (2)

Abdulla Nilam
Abdulla Nilam

Reputation: 38584

To use Session class, In config/autoload.php

$autoload['libraries'] = array('session');

Setting Flash data

$this->session->set_flashdata('item', 'value');//$this->session->set_flashdata('name', 'Rakesh');

after set flash data redirect to method using

redirect('controller/method_name');

Then in view (to show/this will execute when name is set only)

<?php 
    if($this->session->flashdata('name') != '')
    {
        ?> 
        <div class="success">
        <?php $this->session->flashdata('name'); ?>
        </div>
    <?php
    }
?>

To Destroy Session

$this->session->sess_destroy();

Codeigniter Flashdata

Upvotes: 0

oguzhancerit
oguzhancerit

Reputation: 1572

To add flashdata:

$this->session->set_flashdata('stack', 'overflow');

You can use on view with this code:

$this->session->flashdata('stack');

Be sure your web page shouldn't redirect one more times. If your redirection counts is more than one, you need to use:

$this->session->keep_flashdata('stack');

Upvotes: 1

Related Questions