Link to home
Start Free TrialLog in
Avatar of Paer Toernell
Paer ToernellFlag for Thailand

asked on

Access PHP session info from Mysql TRIGGER

Hello,
Trying from the Mysql side get PHP session info. My PHP is ....ancient.  I'm writing a trigger and the trigger need to store some unique info about what PHP session that the trigger belongs to.

Regards Paer
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Pretty sure you can't do that - MySql has no concept of PHP.

Maybe explain a little more about what you're aiming for and we can try and offer an alternative solution
Avatar of Paer Toernell

ASKER

Hello,

I'm trying to create a uncoupled log function. So that all insert, updates an deletes will be logged by a stored procedure initiated by a trigger. Without having to change the PHP code at all or minimal. Problem is I need something unique to identify the PHP session that initiated the Mysql operation. Perhaps an alternative solution is to get the Apache session?
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of skullnobrains
skullnobrains

There is no way to do that unless you pass php's session id to mysql in the php code... or rather the client's address.

It may proove way simpler to track calls directly in apache's or php's logs, or possibly create a dedicated log within the app
Chris, i lake that, probably my solution. But should not the variable have two @ to make it a session variable?

Regards Pär
Hi,

You need to use the single @.

In MySQL there are actually 2 kinds of session variables - user defined and system defined. User defined uses a single @ , whereas system defined uses a double @@. You're creating a user-defined variable, hence the single @
Thanx everyone.