you can use scoreboard... there is a criteria called stat.leaveGame, you can use this to detect when the player rejoin the server, and run effect command to those players score higher or equal to 1. after that, you can set the score to be 0 and wait for the next time
edit:
Add scoreboard objective(detect leave game)
/scoreboard objectives add leaveGame stat.leaveGame
Give effect to the player who joined the game(has left before)
/effect @a[score_leaveGame_min=1] minecraft:resistance <time> 4
Clear their score
/scoreboard players set @a leaveGame 0