Cold symptoms do not linger for more than 7 to 10 days. The green mucus is suggestive of bacterial infection of your nose and/or sinuses. It needn't be bacterial, but could be a fungal infection. You would do well to see an ENT specialist, for a thorough exam to rule out tumors and request that the green mucus be cultured for both bacteria and fungi. Not all doctors deem fungal infection of the nose and sinuses serious enough to warrant treatment. In some cases, a fungus can incite an allergic reaction rather than being infectious, per se.
I would suggest that your phlegm issues are related to allergies triggered while you are sleeping. More than likely it is due to bacteria or dust/dustmite buildup in your bedding. I would try a hypoallergenic pillow cover, plus washing your bedding and pillows about once a week. Another thing you could try is taking an antihistimine before you go to bed at night to see if this helps. My mom always said that when my (pardon the graphics here) snot was green I was clean but if it was clear trouble was near.