1. The need to have intention of this reasoning when dwelling in the Sukkah:
The reason behind dwelling in a Sukkah: The reason G-d commanded us to sit in a Sukkah for shade is so we recall the miracles and wonders done for us in the desert, in which the clouds of glory surrounded us for shade, as protection from the sun.
Intent upon being in Sukkah: When dwelling in a Sukkah one must have intent to do so in order to fulfill G-d’s command to sit in a Sukkah in commemoration of the Exodus. This obligation to have intent during the dwelling is learned from the verse “So you shall know”.
The need to contemplate on the above reason behind the Sukkah: [It does not suffice to merely think about the reasoning mentioned, but rather the main point is for one to contemplate it.]
If one did not have the above Kavana does he fulfill his obligation?
Must one have this intent every time he dwells in the Sukkah?
Yes. Each time one eats in the Sukkah, and fulfills the Mitzvah of dwelling in the Sukkah, he is to intend to fulfill the Mitzvah for the above mentioned reason of commemorating the exodus.
 This ruling of Admur follows the ruling of Rebbe Eliezer in the Gemara. However according to Rebbe Akiva we slept in actual Sukkos, and according to him the reason behind Sukkas is to remember all the kindness that Hashem provides us. [Rashbam]. See as well next note
 Tzaruch Iyun from this wording if one is to intend on the clouds of glory as well as the exodus, or simply intending on the exodus suffices. However from the fact that Admur and Michaber bring the above reason of the clouds of glory it implies that it is this specific intention that one must have. Vetzaruch Iyun according to this why Admur [from Magen Avraham] wrote exodus as opposed to the clouds of glory. To note from Taz  which explains that remembering the exodus is the reason according to Rebbe Akivah, while remembering the clouds of glory is the reason according to Rebbe Eliezer. The Peri Megadim rules that it is implied from the Magen Avraham that there is no need to intend for the clouds of glory, although based on the Taz it is proper to have both intentions. Perhaps according to Admur it is also needed to have both intents and he thus brought down both reasons.
 SH”U 2/267
 SH”U 2/267.
 So is implied from Rebbe that one does fulfill his obligation despite having lack of intention, and so rules the Mishneh Berurah [625/1]. However according to the Bach and others which rule like him without this intent one does not fulfill the Mitzvah, and thus on the 1st night when there is an active obligation to eat in the Sukkah, if one did not have intent he must re-eat a kezayis of bread there!