[dancer-users] database connection in dancer

Dancer New dancerfan2015 at gmail.com
Tue Aug 25 11:38:18 BST 2015


Hi,

I am trying to implement a user login on a website.

Each time a user logon, the session record the user name.

In the database side, there is a store procedure to set the user context so
that for subsequent query, the database will return results based on the
different user.

In my application, there is a 'before hook' to checks the session first and
connect to the database, pass the username to the stored procedure to set
the user context.

so for each request, it will call the 'before hook' first and then start to
query the database.

The problem I have now was the database connection in 'before hook' (
setting user context) and the db connection in the route for actual query
seems two different db connections. So the database doesn't know they are
from the same user request and therefore doesn't return the right results.

How to keep the database connection in 'before hook' and pass the same
database connection to other route?

Your help will be much appreciated!

Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150825/ab4bce5a/attachment.html>


More information about the dancer-users mailing list