how to bootstrap or initialize joomla environment in external script

If you want to get the information about the logged in joomla user in your external script here is theĀ recipeĀ for it: 1. First you need to get the joomla base path eg: http://example.com So something like below might work or you will have to adjust according to the path of your script file $joomlaBase = ...