You cannot do it through a Web application. For apparent security reasons, Web is designed the way that it's not possible to write any remote application which could force a client to do any action. In particular, a Web application cannot get access to a client system, and everything happens by request of a client side. Moreover, if you mention that you want to do something "based on any browser installed", it should mean that it should not assume that any browser is even being executed at this moment, so what PHP can even be discussed?
One exclusion in Microsoft ActiveX. You can install an ActiveX component used on a Web page. But 1) this can work only on certain systems (almost exclusively Microsoft) and compatible browsers, so it is very limiting, please see below; you would have to forget "any browser installed"; 2) ActiveX components for the Web are considered as a very unsafe feature, as it contradicts the security principles mentioned above; 3) you would still need the browser running at the moment of detection.
You can solve such problems only if you develop some client-side software and distribute it to clients on their consent. (If a user get a dongle physically, it means that it is is possible to deliver some software with it.) This software should be installed in client side and it has nothing to do with Web applications. Now, in contrast to Web programming, the problem is that you would be able to develop such software only for limited set of different systems. If you wanted to make a browser plug-in (which would be only natural, imagine that mechanism works is a browser is working; when a user inserts a dongle, this is detected and then the browser will request something at some URI), you would be also limited to some set of browsers and their version. The detection of a dongle is quite possible (I hope this is an USB dongle); if you search Code Project you can find a number of articles on the detection of an USB device:
Detecting Hardware Insertion and/or Removal[
^],
Hardware Change Detection[
^],
find more:
http://www.codeproject.com/search.aspx?q=USB+detect&doctypeid=1[
^].
After all you should know, that if you insert, for example, a USB storage device in nearly any computer system with UI, you get a notification asking you about mounting, of formatting, or browsing the detected media. You can do the same. But again, you need to do it for some set of particular user's platforms, which is a very limiting factor.
[EDIT]
Yes, you can get the USB notification in a Windows Service as well. For development of the Windows Services, please start here:
http://msdn.microsoft.com/en-us/library/y817hyb6.aspx[
^],
http://msdn.microsoft.com/en-us/library/40xe80wx%28v=vs.90%29.aspx[
^].
This CodeProject article can also be helpful:
Simple Windows Service in C++[
^].
Remember that you will have to re-work your projects considerably, to make it a service. First of all, you cannot use any UI (as the service keeps running when everyone is logged off, so there is no a desktop to host any UI). The usual approach is having a separate UI application which communicate to the service application via IPC, when some user is logged on and the desktop is available.
I also developed a technique when the same application can be executed interactively or registered as a service to be executed under the Service Controller. Doing so is yet another known technique, but not so usual. In my case, the interactive part of application does have UI. A big part of debugging can then be done in the interactive mode.
—SA