Logging into Drupal from a non-Drupal site
Use Token authentication

Token Authentication provides a token for use in the URL to authenticate users to your site. It only works on paths configured in the settings page.
Originally this module was intended to offer simple authentication for RSS feeds to allow feed readers to pull customized content listings. You can now use it to provide a simple browsing experience of any Drupal content.

You would need to code a bit behind the scene - namely inject new token to proper table on successful off-site login, but it should be possible.
But maybe for your case opposite approach would be better? You can add custom submit handler to Drupal's login form to get arbitrary PHP code executed.