From 1861 to 1864, Cooper served in the Union Army during the Civil War for three months as first lieutenant in the 4th Pennsylvania Reserve Regiment and for three years as a private in Company C, 26th Pennsylvania Infantry. He served in 13 engagements during the war including Second Bull Run, Chancellorsville, Fredericksburg, Gettysburg, the Wilderness and Spotsylvania Court House.