CDMA and correlation function
In CDMA the spreading is for distributing the energy of each information symbol to a wider bandwidth. In time domain the operation is just multiplication of each symbol with a spreading sequence, that is the same for all symbols. The time period of the spreading sequence is the same as time period of a symbol. However, since the spreading sequence has much higher chip rate than symbol rate, this naturally causes the spread signal bandwidth to increase respectively.

In the receiver, the despreading is done by multiplying with the same spreading code as was used in the transmitter. Since this is effectively the same thing as correlation, you can consider the despreading also as correlation. The key thing in spreading codes is that they are orthogonal, meaning that they do not correlate with each other. So, despreading with a different spreading code gives zero as a result (or zero-averaged noise if despreading is done as sliding correlation). Only using the correct spreading code is able to combine the energy of the spreaded signal. So, mathematically speaking the despreading gives high correlation result for the used spreading code, and zero correlation for the other spreading codes.