ikkez / f3-flash Goto Github PK
View Code? Open in Web Editor NEWAdd simple Flash Messages and Flash Keys to PHP Fat-Free Framework
License: GNU General Public License v3.0
Add simple Flash Messages and Flash Keys to PHP Fat-Free Framework
License: GNU General Public License v3.0
Hey there,
I'm not 100% sure this is a f3-flash issue, but it seems that it's related in some manner. I'm running PHP 7.3.12 and MariaDB 10.3.20 locally. The session and flash messages work 99% of the time. The 1% of the time when it doesn't work, it seems that something odd happens with creating a new session? My local php webserver has been running the whole time, but if a long time passes and then I use it, I get the following error:
Forbidden
HTTP 403 (GET /)
[/project-dir/vendor/bcosca/fatfree/lib/db/sql/session.php:77] Base->error()
[/project-dir/vendor/bcosca/fatfree/lib/base.php:285] session_start()
[/project-dir/vendor/ikkez/f3-flash/lib/flash.php:36] Base->ref()
[/project-dir/vendor/bcosca/fatfree/lib/base.php:35] Flash->__construct()
[index.php:54] Prefab::instance()
On line 30 I setup my db connection, line 36 I setup the new DB session new DB\SQL\Session($f3->db,'sessions',true,null,'CSRF');
, and then on line 54 I add the flash instance. $f3->set('flash', \Flash::instance());
This is the code that throws the error ($fw->error(403)
) in session.php
<?php
function read($id) {
$this->load(['session_id=?',$this->sid=$id]);
if ($this->dry())
return '';
if ($this->get('ip')!=$this->_ip || $this->get('agent')!=$this->_agent) {
$fw=\Base::instance();
if (!isset($this->onsuspect) ||
$fw->call($this->onsuspect,[$this,$id])===FALSE) {
//NB: `session_destroy` can't be called at that stage (`session_start` not completed)
$this->destroy($id);
$this->close();
unset($fw->{'COOKIE.'.session_name()});
$fw->error(403);
}
}
return $this->get('data');
}
I'm just not exactly sure what to fix cause it isn't terribly obvious and going through the code doesn't lead to any clues.
I'm gonna leave some var dumps in there to see if I can figure out if the ip change or the agent changes.
Hello,
Sorry it's more question than an issue I suppose but I would ilke to know what to do to close the Flash Message because the button doesn't do anything.
Regards,
Alain
I don't know if this is intended but,
If you use \Flash::instance()->getMessages() before using \Flash::instance()->addMessage() then getMessages() will return null instead of empty array.
Subsequent invocations of getMessages() return empty array because getMessages() calls clearMessages().
i have this code in my base controller's afterroute:
$flash = Flash::instance()->getMessages();
$flash ? $f3->set('FLASH', $flash) : $f3->set('FLASH', 'empty');
and when i try to generate a CSRF code with:
(i have cache on)
$s = new Session();
$f3->CSRF = $s->csrf();
i get this error: (if i comment the 1st code that instances flash, then no error)
session_start(): Failed to read session data: user (path: E:/laragon/tmp)
[E:/laragon/www/base/vendor/bcosca/fatfree-core/base.php:2152] Base->error()
[E:/laragon/www/base/vendor/bcosca/fatfree-core/base.php:273] session_start()
[E:/laragon/www/base/app/inc/Flash.php:31] Base->ref()
[E:/laragon/www/base/vendor/bcosca/fatfree-core/base.php:35] Flash->__construct()
[E:/laragon/www/base/app/controller/BaseController.php:9] Prefab::instance()
[E:/laragon/www/base/vendor/bcosca/fatfree-core/base.php:1782] BaseController->afterroute()
[E:/laragon/www/base/vendor/bcosca/fatfree-core/base.php:1599] Base->call()
[E:/laragon/www/base/public/index.php:32] Base->run()
Code for button in bootstrap v5 is:
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
Docs: https://getbootstrap.com/docs/5.1/components/close-button/
BugFix: https://stackoverflow.com/questions/68223442/bootstrap-alert-button-design-is-off-and-doesnt-close-when-clicked
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.