Welcome Guest, Not a member yet? Register   Sign In
losing sessions user_data after redirect
#1

[eluser]Zefirs[/eluser]
Hello everyone!
Sessions are saved in database.
In controller I set_userdata(data['test']) and print out the session data to screen.Everything is ok, but! After i redirect to view, and print session data again, inserted data does not show up anymore. Why?
#2

[eluser]Cristian Gilè[/eluser]
Please, post your code.


Cristian Gilè
#3

[eluser]Zefirs[/eluser]
Controllers function, adds product in usersdata
Code:
function addToCart (){
$this->load->model('product_model');
$xdata=$this->product_model->getProdFromId($this->input->post('id'));
$insert['items'] = array  (
               'id'      => $xdata->id,
               'qty'     => '111',
               'price'   => $xdata->price,
               'name'    => $xdata->name,
           'info'    => $xdata->info
                           );
$this->session->set_userdata($insert);
//print_r($this->session->userdata); ! If i use print in controller userdata contains data
redirect('content');
}
After redirected to view,
Code:
<?php
print_r($this->session->userdata); ?>

After redirect i cant see any added data to session...
#4

[eluser]Zeeshan Rasool[/eluser]
Do this happens in all browsers? Also are you facing this issue with all redirections ?
#5

[eluser]Zefirs[/eluser]
This happens in all browsers. Because its the only one redirect, cant answer the second question.
#6

[eluser]InsiteFX[/eluser]
1) Are you using database sessions?
2) Are you using AJAX calls?
3) Cookies only hold 4Kb of data.
4) The database session table may need the user_data field changed to mediumtext.

InsiteFX
#7

[eluser]cideveloper[/eluser]
Code:
redirect('content');
redirects you to the controller content. You keep on saying redirect to view. So when you redirect to the controller content with no method specified you will be calling the index function. Is this where you are loading a view that has the code
Code:
<?php print_r($this->session->userdata); ?>
. Have you checked your database to see if the data is being saved. Easiest first step.
#8

[eluser]Zefirs[/eluser]
Session is saved in database. I checked if data is in database - and it is!
When I redirect('content') index function loads the view.
In the view i have this line <?php print_r($this->session->userdata); ?>.
All browsers display the same - no user data.
#9

[eluser]InsiteFX[/eluser]
Code:
$this->cart->insert($data);

InsiteFX
#10

[eluser]cideveloper[/eluser]
I know this might be a crazy question but are you autoloading the session class or loading it on a per controller basis.




Theme © iAndrew 2016 - Forum software by © MyBB