Temperature is a very important factor to consider when growing cannabis. The temperature of your grow room will have an effect on the rate your plants photosynthesize ( the process in which they turn carbon dioxide, water and light into food). If your grow room is at the incorrect temperature, your plants will not be able to photosynthesize efficiently, thus negatively impacting the rate at which they grow.
In a standard, well ventilated grow room the optimal temperature tends to be between 24-29 °C (75-85 degrees Fahrenheit). There are however, other factors that can warrant higher temperatures. For example, if you are enriching your cannabis crop with extra carbon dioxide then you will need higher temperatures for it to be efficient, usually around 30-32 degrees Celsius (86-90 degrees Fahrenheit).
The reason for this is that higher temperatures stimulate an increased metabolism within cannabis plants (up to a certain point). Assuming that there is ample carbon dioxide and light for the plants to use, they will be able to produce a lot more energy, and display stronger growth and bud production as a result.
Temperature also has an effect on internodal length. Ideally you want to try to keep this to a minimum in order to grow denser, more efficient buds. The internodal length is directly related to the difference between night and day temperatures. The greater the differences between your day-time and night-time temperatures, the longer the internodal lengths grow. The closer these temperatures are, the smaller the internodal lengths.
As an example, let’s say your grow room is at the normal optimal day-time temperature of 75 degrees Fahrenheit (24 degrees Celsius). To reduce internodal length growth you will want to try to maintain the temperature at 71 degrees Fahrenheit (22 degrees Celsius) at night.
This technique is most effective during the first 2-3 weeks of the flowering period  when you have just switched to a 12/12 photoperiod. This is when cannabis plants put a lot of effort into their pre-flowering growth, creating the building blocks for their colas. At this phase, you will want to consider increasing the night-time temperature to match the day-time. This will really minimize the massive internodal growth associated with this time period and allow your cannabis plants to focus on growing much denser buds. Look at it this way: what use is extra stem to you? Surely you would rather your plants direct their energy into bud growth rather than throwing it away with longer stems?
After the initial 2-3 weeks you can reduce the night-time temperature back to its original 71 degrees Fahrenheit (22 degrees Celsius). This will stop the plant getting stressed. If there is a zero difference between night and day temperature for more than three weeks, your plant leaves may begin to discolour due to leaf chlorosis.
Another important factor to consider during the flowering phase is that total bud size is largely impacted by the average daily temperature. It is important you make sure that temperatures do not drop below their day and night optimum; doing so will cause your buds to grow less than their potential.
Extra Tip: Reducing the night temperature to 62-66 degrees Fahrenheit (17-19 degrees Celsius) for the last two weeks of flowering will trigger the production of anthocyanin. This will really bring out the colour of your buds,  making them look much more appealing. This is usually done once buds have reached their maximum size and you have started the final flushing process. It is not essential however, and can be overlooked if it is not practical - it is a purely cosmetic consideration.
As you can see, temperature can have a large effect on how your cannabis plants grow. If you can get it just right then you will find that the quality of your grow increases dramatically. It takes practice, but with perseverance you will find yourself well on the way to becoming a much more accomplished cultivator.