Some dish detergent might work, depending on what actually stained. If it is an oil based sunscreen, you need something that will cut the oil.
After you try the less caustic measures, you might go ahead and use bleach. That's what I always end up doing with white cotton shirts (I have two from Renshirts, one a heavier weight that hold up well). I use a plastic tub that fits in my kitchen sink, put in some hot water, a cup of bleach (yeah, I know, I know, too much, but that's what I do), a cup of laundry detergent, swish it with my hands to mix it up, add the shirt and make sure it is completely submerged. I soak the shirt for a while (maybe 10 minutes, maybe overnight), toss it in my washer along with some white towels for a cycle and see what happens (the towels help to agitate the fabric). Sometimes I do it a couple times to get stains out.
I have had to do this several times to get out stains like the red stain from a new leather belt, the red from an overshirt when I was caught in the rain, make up stains, hair dye, etc.
This should be a last ditch effort because the bleach will "eat" away at fabric, including cotton.