Cut cotton fabric into a rectangle that is the length of the pillowcase plus 1 inch and twice the width of the pillowcase plus 1 inch. Lay the rectangle of fabric on a flat surface and make sure the side you want on the outside is facing up with the long edges at the top and bottom. Fold the top edge down and line it up with the bottom edge.
Pin the two long sides together ½ inch in from the edges. Sew a straight seam here and take out the pins as you go. Snip off the extra thread.
Choose one end of the fabric and pin the two short edges together there. Place the pins about ½ inch from the edge again. Sew another straight seam to close this side and trim off extra threads.
Turn the fabric right side out and use a knitting needle to reach in and poke out the two finished corners completely. Measure the width of the fabric and divide it into equal thirds. Mark these thirds onto the fabric with fabric chalk.
Pin along the lines you marked to create three compartments. Pour rice into each compartment through the open end of the fabric. Do not overfill the pockets; the fabric should remain fairly flat when the pad is laid down.
Sew along each line of pins to permanently separate the compartments, removing pins as you go. Turn ½ inch of the open edges inward and pin the edge closed. Sew a straight line of stitches along the pinned line to close up and trim off any extra threads on the cool pad.
Place the cool pad in the freezer for several hours. The rice will retain the cold for a long time but will not get hard like a water- or gel-based cool pack. Slide the cool pack between your pillow and the top of the case for a cool place to fall asleep.