Are swollen glands a sign of a viral or bacterial infection?
It is important to remember that lymph nodes trap the foreign antigen, which serves to isolate the antigen and neutralize it, also to make copies of it with the B lymphocytes.
This is what is causing the inflammation. Bacteria and viruses alike have antigens in them as well, and therefore swelling of lymph nodes can be viral or bacterial in origin.
To differentiate them, further test should be done. One of the simplest test that can be done is the Complete Blood Count.
Majority of viral infections causes a lymphocytosis(increase in lymphocytic count) and bacterial infections have a leukocytosis(increased WBC count) but has a more pronounced increase in neutrophils.