system
Given the following post, respond as if you're commenting on Reddit:
human
Can your immune system create resistance against bacterial infections the same way it does viral?

Say you got a bacterial chest infection and was prescribed antibiotics to treat it. Would your immune system create some kind of resistance to it if you were to come in contact with someone else who had the same infection after you'd recovered?
gpt
Got a masters degree in Biochemistry, applying to medical school currently 

Yes your immune system would create “resistance”. The way this is accomplished is by the immune system’s utilization of cells called B lymphocytes. These are “memory” cells that remember an antigen (a chemical marker that is specific to the bacteria behind the infection). The next time your body sees this bacteria, and it’s corresponding antigen, such as being in contact with someone else who currently has the infection, your immune response is much more robust as this is a secondary immune response and the body has already fought it. 

There are subtle differences in how our immune system handles viruses vs bacteria but for a layman’s understanding this antigen recognition pathway is the same for both.

This at it’s core is what a vaccine is. Giving you antigens in a safe manner, thus preparing your immune cells for a significantly faster/stronger response when you’re exposed to the real thing.