How to track session of visitors (time of visits at particular page) and show ads if visitor clicks on defined link at URL and/or session comes within particular time?
Is there some the best professional PHP script to manage this with support of PHP and database?
Um, you didn't want tracking software yet you asked "How to track..." ?? Gee, sorry for barking up the wrong tree there!
Okay, your new explanation sounds a little better, although it's kind of vague when you made up this cool terminology, "smart detect".
Sounds to me like you want to store session times (you used plural so that means you want a history of visits) per page as well as clickthru's and use that information to dynamically display adware links to the user based somehow. Meaning you'd need to implement PHP session support, database support and code to do the analysis in real time.
Please note for the record that all major analytics including Google, piWik and Webtrends to name just 3 all allow you to set goals based on triggers by embedding simply code into the body tag of a page. The software already tracks session time and clickthru's, and you would define goals based on session times and/or URL's for that client and create goals which means do something (like output an adware popup or redirect or link to an adware site).
PiWik *is* the "professional PHP script" you asked for, if I follow your request now that you've restated it. If I still am off target, it aint for a lack of trying on my part! All I can do is apologize if I am missing something obvious here.