If he had three brothers, the third got nothing, and the second brother got cookies twice!
Assuming he gave everything away, and working backwards:
"Finally, he gives half of what is now left and half a cookie to his second brother."
means at the end, he gave away the last one. (half of ONE that is left, and the other half).
"He then gives half of what is now left and half a cookie to his second brother."
So he had three to start, half of what is left is one and a half, plus half makes two. That leaves one.
"To the oldest, he gives half of the cookies and half a cookie."
After this, he had three, so half is three and a half, and he started with 7.
Conclusion: he started with 7 cookies.
In fact, if he had N brothers, he needs a minimum of 2N-1 cookies to start with.