<?php

namespace HwapX\Core\Library {

  use F3;
  use Session as F3Session;

  class Session extends F3Session {

    protected static $instance = null;

    public function __construct($onsuspect=NULL,$key=NULL,$cache=null) {
      parent::__construct($onsuspect,$key,$cache);

      //F3::set('SESSION.flash', array());
    }

    public static function instance() {
      if(self::$instance == null)
        self::$instance = new Session();

      return self::$instance;
    }

  }
}

namespace {

function flash($k) {
  $f3 = F3::instance();
  $k = 'SESSION.flash.'.$k;
  $r = null;

  if(func_num_args() == 1) {
    if($f3->exists($k, $r))
      $f3->clear($k);
    return $r;
  } else {
    $f3->set($k, func_get_arg(1));
  }
}
}