Welcome Guest, Not a member yet? Register   Sign In
my session did not show
#1

[eluser]yudahebat[/eluser]
I have a controller
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->set_userdata(array('nama' => $this->input->post('nama'),'photo' => $this->input->post('photo'),'harga' => $this->input->post('harga')));
    
        $this->load->view('v_cart',$data);
    }

and views

Code:
<table width="645" border="0" cellpadding="0" cellspacing="0" class="tabel" >
                <tr>
                    <td width="130" 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="80" 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>
                &lt;?php foreach ($this->session as $row)
                      {?&gt;
                <tr>
                    <td width="130" class="tabel"><p>&lt;?= row->$this->session->userdata('nama');?&gt;</p></td>
                    <td width="110" class="tabel"><p>..</p></td>
                    <td width="110" class="tabel"><p>..</p></td>
                    <td width="80" class="tabel"><p>..day</p></td>
                    <td width="100" class="tabel"><p>$ &lt;?= row->$this->session->userdata('harga');?&gt;</p></td>
                    <td width="110" class="tabel"><p>$..</p></td>
                </tr>
                &lt;? } ?&gt;
                <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, its not show anything..
help me please
#2

[eluser]Dam1an[/eluser]
I think you want to pass it through in the data array
Sessions are meant for maintaining state between requests, but you're still in the same request when you load the view

Does this not give you any errors, assuming you have reporting enabled
#3

[eluser]yudahebat[/eluser]
yep its error
it shown like this
Code:
Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in C:\xampp\htdocs\CI2\system\application\views\v_cart.php on line 25
#4

[eluser]pistolPete[/eluser]
Did you enable error_reporting?
Are short open tags (&lt;?) enabled on your server?
#5

[eluser]sl3dg3hamm3r[/eluser]
Why not copying out this line 25 for the community? Actually, everything is said in the error-report.
Guess there is also soon a sticked post "how to debug correctly in php" necessary, as you would find it in every other php-forum...
#6

[eluser]yudahebat[/eluser]
line 25 :
Code:
<td width="130" class="tabel"><p>&lt;?= row->$this->session->userdata('nama');?&gt;</p></td>
#7

[eluser]Thorpe Obazee[/eluser]
[quote author="sl3dg3hamm3r" date="1245175860"]Why not copying out this line 25 for the community? Actually, everything is said in the error-report.
Guess there is also soon a sticked post "how to debug correctly in php" necessary, as you would find it in every other php-forum...[/quote]

They want you to guess.
#8

[eluser]Thorpe Obazee[/eluser]
[quote author="yudahebat" date="1245172126"]

Code:
<table width="645" border="0" cellpadding="0" cellspacing="0" class="tabel" >
                <tr>
                    <td width="130" 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="80" 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>
               [b] &lt;?php foreach ($this->session as $row)
                      {?&gt;[/b]
                <tr>
                    <td width="130" class="tabel"><p>&lt;?= row->$this->session->userdata('nama');?&gt;</p></td>
                    <td width="110" class="tabel"><p>..</p></td>
                    <td width="110" class="tabel"><p>..</p></td>
                    <td width="80" class="tabel"><p>..day</p></td>
                    <td width="100" class="tabel"><p>$ &lt;?= row->$this->session->userdata('harga');?&gt;</p></td>
                    <td width="110" class="tabel"><p>$..</p></td>
                </tr>
                &lt;? } ?&gt;
                <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, its not show anything..
help me please[/quote]

yudahebat, did you really want to iterate through the CI Session object?
#9

[eluser]yudahebat[/eluser]
actually I want to looping my session
so every I input data from another views, the table add 1 data without replace last entry data
#10

[eluser]Thorpe Obazee[/eluser]
[quote author="yudahebat" date="1245235773"]actually I want to looping my session
so every I input data from another views, the table add 1 data without replace last entry data[/quote]

did you ever try looking into $this->session? If you didn't use print_r($this->session). It has a lot lot more than what you need.

What you'd want is $this->session->userdata.




Theme © iAndrew 2016 - Forum software by © MyBB