user not logged in php file I want use drupal functions in php files,I did it with below code

$path = $_SERVER['DOCUMENT_ROOT'];
chdir($path);
define('DRUPAL_ROOT', getcwd()); //the most important line
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);


Its ok and good fine, after this all drupal function exist,but my problem is here
when user logged in before this page when redirect to this page it not know as logged in user (it know as anonymous user ), how can have logged in user in php file ?

I try  drupal_session_regenerate() after below code but nothing happened, how can solve this problem?
This forum post on d.o explains what may be your problem.

You need to: 


  Set $cookie_domain='example.com'; explicitly in your settings.php file. 


According to the post, Drupal keeps a long session ID string in a cookie, and without a proper cookie domain, the current user is anonymous.