How can you prevent CSRF attacks?

* CSRF Tokens : Generate a unique, unpredictable token for each user session. Include this token in hidden form fields or HTTP headers for all sensitive requests. The server-side validates the token before processing the request.

* SameSite Cookie Attribute : This attribute restricts the scope of cookies, preventing them from being sent in cross-site requests.

* HTTP Methods : Use HTTP methods like POST for sensitive actions instead of GET, as GET requests can be easily manipulated in URLs.

* Double Submit Cookie : Send a randomly generated token in both a cookie and a hidden form field. The server-side compares the two tokens for validation.