I think you might be going about this all wrong... or at least that is my opinion.
When playing war, player one and player two are both dealt a hand of cards, or 1/2 the deck. You might represent these cards as arrays that are held in a cookie or session array. These arrays would be added to (if the player wins), or subtracted from (if the player loses), but in your game the cards come from a sizeless deck that doesn't ever ends. Also, the cards in each players hand do not get played randomly in a real game of war. The card that is played comes off the top of the players dealt hand (which is face down in front of them). So, I think you need to go back to the basics of how to play the game of war, and then think about using cookies or the session array to hold your cards. There's only 52 cards in a deck, and none of them are the same (with the exception of jokers). Again, consider using cookies or the session array.