The present invention is a method and system that provides user tracking functionality for web databases. The system enables tracking of all activities from the end user through the Web application to the database, without requiring any changes in existing databases, and web applications. The user-tracking ability provided by the invention provides a basis for fine grained access control. Such user-tracking ability is required for the identification of logical sessions, which are crucial to intrusion detection techniques. The users tracking ability can be used to monitor the actual access privileges of users and can be used for role mining and role engineering. The latter application is extremely important for legacy applications.