If I know in advance that I might need to do something like this, I will book a different London airport for the connection, eg: XXX-LHR,then LGW-YYY, or if that isn't possible, book the LHR connection overnight. Last time I checked LHR won't store bags overnight ( but that was over 10 years ago, obviously things change).