in reply to session with mysql database.

“If you are using Dancer2, then use all of Dancer2.”   Session-management and lots of other things are already handled by available plugins which you can either use or slightly-adapt.   “Taking a nice stroll through CPAN” should be the very first thing that you do.   Indeed, that’s the point of using a good framework.   “Do not do a thing already done.™”