In this study, a thermosensitive in situ gel with porous structure was developed using poloxamer (Po) and N-(2-hydroxy-3-trimethyl ammonium) propyl chitosan chloride (HTCC). The poloxamer-quaternized chitosan (Po-HTCC) in situ gel exhibited superior rheological property, water absorption capacity and antibacterial activity against Escherichia coli, Staphylococcus aureus, Pseudomonas aeruginosa and Streptococcus pyogenes, making it well-suited for ocular applications. Scanning electron microscope revealed a macroporous architecture with pore sizes ranging from 1 to 2 μm, suggesting that the gel has desirable breathability, corneal adhesion capability, and overall conformability. In vitro drug release assay was conducted with levofloxacin hydrochloride, demonstrating that sustained release over 48 h could be achieved at 34 °C, with approximately 80 % of the drug released within this timeframe. Computational simulations revealed substantial binding affinity between the material and the Escherichia coli outer membrane lipopolysaccharide-associated protein and corneal mucin. The protein showing the strongest binding energy to N-(2-hydroxy-3-trimethyl ammonium) propyl chitosan chloride (HTCC), as calculated by the Molecular Mechanics Generalized Born Surface Area Method (MM-GBSA), was LptD-LptE, with a binding energy of -61.14 ± 4.72 kcal/mol. These results underscore the potential of this system for effective and convenient ocular delivery with sustained drug release.