We examine consumption and investment decisions in a life-cycle model with habit formation, stochastic opportunity set, stochastic wages and labor supply flexibility. Retirement is taken into account by specifying an age at which labor earnings stop, but consumption spending continues. Explicit solutions are obtained for optimal consumption, labor supply and the financing portfolio. We examine the structure and determinants of the optimal portfolio. We also study the effects of the retirement date and of habits on optimal decisions. Finally, we conduct a preliminary analysis to assess the effects of a liquidity constraint on optimal consumption-leisure choices.