Check the cables with a computer. Often times the computer will have issues recognizing the phone if the cable is going bad, making this an extra verification that this is the issue. Wiggling the cable right behind the micro-USB plug will also affect its ability to charge (I.e. Connect/disconnect, or affect the charging rates) in most cases because it's the most common failure point.
I'm of the opinion that micro USB is just a poor design for charging all together. I've tried cheap and premium cables, and all of them tended to go bad within 6 months (As opposed to the old proprietary power cables before USB became standard, which lasted me years). The brand I've settled on for those is Volutz, sold on Amazon. They are a braided cable and a good value for longevity.
I'm just now starting to use USB C cables, so I have no idea how those will hold up.
It's also possible the port in the phone is starting to loosen up, which causes similar symptoms. Usually this means even brand new cables have these issues from the start.