How long is supposed to take cognitive therapy to work?

Dpends. Cognitive behavioral therapy can be effective within a few weeks but taking months or longer to accomplish the intented goals and effects.
Treatment time. Most amount of change occurs in first 8-12 sessions or so according to most research, but depends heavily on what it is that is being treated and where a person is in being prepared to work on making changes.. Longer term work can help with relapse prevention. There are some outcomes that are hard to quantify, longer work can provide some important help that may not be easily seen in research.