Welcome Guest, Not a member yet? Register   Sign In
why session not work?
#1

[eluser]yudahebat[/eluser]
i hav a function like this
Code:
function v_cart()
    {
        $data['css']         = $this->css;
        $data['base']         = $this->base;
        $data['menu_web']     = $this->menu;
        $data['myrobots']     = '<meta name="robots" content="noindex,nofollow">';
        $data['mywebtitle'] = 'mrputucar | Your cart';
        
        $this->output->enable_profiler(TRUE);
        $this->session->sess_create();
        $this->session->set_userdata(array('nama' => 'avanza','photo' => 'ii.jpg','harga' => '500'));
    
        $this->load->view('v_cart',$data);
    }

and my view

Code:
<table width="645" border="0" cellpadding="0" cellspacing="0" class="tabel" >
                <tr>
                    <td width="110" class="tabel" align="center"><p>Car Type</p></td>
                    <td width="110" class="tabel" align="center"><p>Rent date</p></td>
                    <td width="110" class="tabel" align="center"><p>Return date</p></td>
                    <td width="100" class="tabel" align="center"><p>Duration</p></td>
                    <td width="100" class="tabel" align="center"><p>Price/day</p></td>
                    <td width="110" class="tabel" align="center"><p>Suhtotal</p></td>
                </tr>
                <tr>
                    <td width="110" class="tabel"><p>&lt;? $this->session->userdata('nama');?&gt;</p></td>
                    <td width="100" class="tabel"><p>..</p></td>
                    <td width="100" class="tabel"><p>..</p></td>
                    <td width="120" class="tabel"><p>..day</p></td>
                    <td width="100" class="tabel"><p>$&lt;? $this->session->userdata('harga');?&gt;</p></td>
                    <td width="110" class="tabel"><p>$..</p></td>
                </tr>
                <tr>
                    <td colspan="4" class="tabel2"><p>&lt;?php echo form_submit('', 'Update your Cart'); ?&gt;</p></td>
                    <td  class="tabel2"><p>Total</p></td>
                    <td  class="tabel2"><p>$...</p></td>
                </tr>
                    
                </table>

but when I run it. the session not work
Code:
&lt;? $this->session->userdata('nama');?&gt;
and
Code:
&lt;? $this->session->userdata('harga');?&gt;
didn't show anything,whats wrong??
anyone cant help me?
#2

[eluser]Thorpe Obazee[/eluser]
Try removing this line

Code:
$this->session->sess_create();
#3

[eluser]gtech[/eluser]
also to echo content in the view you need the &lt;?= tag

e.g.
Code:
&lt;?= $this->session->userdata('harga');?&gt;

or

Code:
&lt;?php echo $this->session->userdata('harga');?&gt;
#4

[eluser]Thorpe Obazee[/eluser]
[quote author="gtech" date="1245070383"]also to echo content in the view you need the &lt;?= tag

e.g.
Code:
&lt;?= $this->session->userdata('harga');?&gt;

or

Code:
&lt;?php echo $this->session->userdata('harga');?&gt;
[/quote]

omglol. didn't see that at all!

yudehubat, try using the profiler class too.
#5

[eluser]yudahebat[/eluser]
yep, it work now... thanx gtech..
I forget to use 'echo'




Theme © iAndrew 2016 - Forum software by © MyBB