Call a function in one of the modules from a custom PHP file on my Drupal site
All php files inside drupal cannot be directly accessed by incoming request. You should create a endpoint for $.get which can be done by hook_menu

function mymodule_menu() {
  $items['mymodule/endpoint'] = array(
    'page callback' =&gt; 'mymodule_page_callback',
    'type' =&gt; MENU_CALLBACK
  );
  return $items;
}

function mymodule_page_callback() {
  module_load_includes('php', 'mymodule', 'set_session2');
  // call function here.
}


module_load_includes can include the php file you want from the module. So please place the php file inside the module folder.

In javascript, just update the url to the one you just defined.

...
...
inline:function(){
    $.get("/mymodule/endpoint");
    return $.urlParam('inline', $(this).attr('href'));
},
...
...