if set global transaction, how can I commit?
BEGIN or START TRANSACTION initiates a transaction.  It is ended by COMMIT or ROLLBACK in the same connection.

SET TRANSACTION provides optional attributes for the transaction; it is not often used.

If you need a long-running transaction, or something that spans multiple web page invocations, you need to do it some other way.  (This is probably a common question on this forum.)