Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Session flash help needed
  • Hi,
    I created a new class called Status, which is used to show notification messages. It works, when I redirect the page (the notif. shows up), but when I only set the message it won't show p on the same page (I don't redirect the page.) The class
    class Status { public static $_status = array();
    public static $_new = array(); final private function __construct() { } public static function _init() {
    static::$_status = Session::get_flash('status', array());
    return true;
    } public static function get($type = null) {
    if ($type and array_key_exists($type, static::$_status)) {
    return static::$_status;
    } else {
    return static::$_status;
    }
    } public static function set($status = null, $type = 'success') {
    if ($status) {
    static::$_new[$type][] = $status;
    static::save();
    return true;
    }
    return false;
    } private static function save() {
    Session::set_flash('status', static::$_new);
    return true;
    } } I don't what the problem is. Is it possible the show it on the same page? Thanks
  • You get the messages from flash in the init method, so you'll only see the messages already defined when the class is loaded.
  • You are right, but the flash is set on the previous page. It should be accessible on the actual page, shouldn't it? Does my class load before the session class? I defined the load in the config.
  • I can't comment on that, I can't see your code. If you "Always load" your classes, it should be loaded before the Session class. Session is not loaded by default, the first method call will trigger the load.

Howdy, Stranger!

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

In this Discussion