Longshore currents:

Waves usually approach the coast at some acute angle rather than exactly parallel to it. Because of this, the waves are refracted as they enter shallow water, which in turn generates a current along the shore and parallel to it. Such a current is called a longshore current, and it extends from the shoreline out through the zone of breaking waves. The speed of the current is related to the size of the waves and to their angle of approach. Under rather quiescent conditions, longshore currents move only about 10-30 centimetres per second; however, under stormy conditions they may exceed one metre per second. The combination of waves and longshore current acts to transport large quantities of sediment along the shallow zone adjacent to the shoreline.

These currents also cause a person to drift down the beach while swimming in the ocean. They are also the cause of rip currents (known incorrectly as riptides). The longshore currents flow behind sandbars but if the sand bar is broken at a point, causing water in front of the bar (on the beach side) to flow out towards sea. This current is very strong and is the cause of many swimming accidents.
    Important: Swimmers caught in a rip current should not attempt to swim shoreward directly against the current. Instead, it is best to swim a short distance parallel to the beach to emerge from the rip current before returning to shore.