CodeIgniter Forums
why doesn't this work - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: why doesn't this work (/showthread.php?tid=44624)



why doesn't this work - El Forum - 08-21-2011

[eluser]Unknown[/eluser]
trying to get a mental grip on how flashdata works.

with this controller (session loaded by autoload.php):
Code:
<?php

class Flashtest extends CI_Controller {
    function __construct() {
        parent::__construct();
    }
  
    public function index() {
        $this->session->set_flashdata('message', 'session data set');
        $this->load->view('view_flashtest');
    }
}

and this view
Code:
<html>
<head><title>flashtest</title></head>
<body>
    <div>
    ============================<br/>
&lt;?php echo $this->session->flashdata('message'); ?&gt;<br/>
    ============================<br/>
&lt;/body&gt;
&lt;/html&gt;

I don't get the message displayed until I refresh the page.
Why? Shouldn't the flashdata display when the view loads (without a page refresh)?