In the winter sometimes I want a hat with a little extra oomf to keep my ears warm, so I adda knit lining band around the brim and attach it on the inside. Using the provisional cast on method to hold live stitches, I have knit up the lining of my hat and enough right side rows to match the lining size. Once I've done the prep rows I'm ready to attach my lining on the inside of the hat, knitting two stitches together using three needles.
When you first attempt this method you might feel a little lost, but trust that the pieces come together in the end. Just hold onto your needles as you're folding the lining to match the right side of the brim - they like to fly off the needles sometimes.
Another trick I learned is to work a purl row at the base of the brim, this will allow the lining to fold in and tuck into the inside of the hat easily. The alternative is that you'll end up with a roll, or a tube that doesn't lie flat.