steps towards cookie based setup .. still messy code