I think it is possible to use only cosine function, but why the formula is used with sine?
I am trying to understand but don't know what to do after Fourier transform with imaginary part and real part.



Why do we use sine and cosine in fourier transform together?
I'm not sure which Fourier transform you mean, but I have only seen Fourier series written where the phase, e.g. $e^{2\pi i n x}$ for some integer n, is decomposed into its real and imaginary parts $cos(2\pi n x) +i sin(2\pi n x)$. Since sine and cosine are related to each other by translation, $sin (\pi/2 - x) = cos (x)$ and similarly $cos (\pi/2 - x) = sin (x)$ (this is a classic trig identity and is an instance of the sum angle formula where one of the angles is $\pi/2$ and one is -x). You can rewrite the above expression in terms of only sines or only cosines. The choice of sine or cosine is up to the author and purely a matter of preference. There is no "best way" to write the Fourier series. 


Writing Fourier series in terms of sines and cosines seems to be antiquated within mathematics; I don't know if it is still popular in physics or engineering. Most modern books on Fourier series (e.g. any of Stein's books on Fourier analysis) write formulas in terms of the complex exponentials above. This is in part because the Fourier transform on the real line is written similarly, all the necessary information is encoded in the exponential like orthogonality relations and most likely because it's easier to write.


As far as what to do "after Fourier transform", I don't know what you mean. Could you please explain?


