It depends on the terms of the contract. In most cases, magazines buy first print rights. After the story has appeared in print, you are free to sell it ( or use it) again. In some rare cases, the terms may be different, and the magazine may retain the rights, say because they foresee a reprint or publishing an anthology. It should all be spelled out in the contract they offer. If you want to retain the rights, read the contract carefully. Don't sign or take money if the terms don't match with your future plans.
Good Luck -Craven