Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Error by using Response::redirect before Session::set
  • What same problem? Can you be more specific? What are you doing? What happens?
  • Error:
    Fatal error: Uncaught exception 'Fuel\Core\FuelException' with
    message 'The session data stored by the application in the cookie
    exceeds 4Kb. Select a different session storage driver.' in
    /home/zeeshankhattak/projects/fuelphp/folio/fuel/core/classes/session/driver.php:464
    Stack
    trace:
    #0
    /home/zeeshankhattak/projects/fuelphp/folio/fuel/core/classes/session/cookie.php(111):
    Fuel\Core\Session_Driver->_set_cookie(Array)
    #1 [internal function]: Fuel\Core\Session_Cookie->write('', Array)
    #2
    /home/zeeshankhattak/projects/fuelphp/folio/fuel/core/classes/event/instance.php(163):
    call_user_func(Array, '', Array)
    #3
    /home/zeeshankhattak/projects/fuelphp/folio/fuel/core/classes/event.php(75):
    Fuel\Core\Event_Instance->trigger('shutdown', '', 'none', true)
    #4
    /home/zeeshankhattak/projects/fuelphp/folio/fuel/core/bootstrap.php(33):
    Fuel\Core\Event::shutdown()
    #5 [internal function]: {closure}()
    #6 {main}
    thrown in
    /home/zeeshankhattak/projects/fuelphp/folio/fuel/core/classes/session/driver.php
    on line 464 



    My Controller code:
    $this->view->set_global('val', $val, false);

    View:
    <?php if (isset($val)): ?>
     <div class="alert-message error">
      <?php foreach($val->error() as $e): ?>
        <?php echo $e->get_message(false, '<p>', '</p>');?>
      <?php endforeach; ?>
     </div>
    <?php endif; ?>

    Couldn't solve my problem.
  • Your code snippet doesn't use the session class, so that is absolutely not the cause of the problem. Passing validation objects to a view is unrelated to the error message.
  • Hello,

    I have a problem with the cart package.
    When I add 7 products, it works. But when I want to add an other product, it erase the last product added.
    The cookie is near from 4Kb. 
    I try to change the config : 'driver' => 'session' or 'driver' => 'cookie', but there is no change.

    Would you have an idea ?
  • That must be something in the code, and not related to the session. If you get to the 4K boundary for cookies, you would loose the entire session, including logged-in state, and not only the last product.

    Since I don't know the "cart package", I can't really comment on what is going on, I guess some debugging is in order.

    You could (temporary) switch to database sessions, those are stored as serialized array's, so you can see what exactly is stored in the session. It might help with the debugging.
  • Thanks for the prompt reply. I switch to the database session. It works, but a lot of informations are save in DB. I tried the file session and it works too.
    I think i will keep this solution.
    But I don't understand why the cookie sessions is not appropriate in this case ...

    Thank you Harro.
  • I can't say, I can only imagine that (also given your reply) the cart package saves a lot of data in the session.

    Don't forget that cookies are encrypted, and it is the encrypted size that counts, so it's quite possible for a session containing an array of 8 products, encrypted, to produce a string larger than 4Kb.
  • It's impossible to store session after redirection
  • Redirection ends processsing the code, it is considered to be be same as exit.

    This is documented: http://fuelphp.com/docs/classes/response.html#/method_redirect.

    So anything you want to do, you have to do before you redirect. The only things that will be executed after a redirect are events that are triggered after the contoller has finished.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion