A longshore current can be a tidal current or a wind driven current. We will look into the wind driven current. The wind driven current is occurring if the wave direction is not perpendicular to the beach. The wind-driven current is only present in the breaker zone. This is different with the tidal current, which is present also in the full sea.
In the sketch, waves A come to the shore under a corner. As soon as the wave is reaching the breaker zone it will start breaking at the side first and start bending a litter bit towards the beach line. A current B is the result. This current is the wind-driven longshore current. However it is not the wind but the wave direction which is responsible for the current. The wave direction is depending on the wind direction, but after a large storm the swell can come from a direction which is not the same as the wind direction. If the waves come from the opposite direction (from the right) the current will go to the left.
Wind-driven current and tidal current can be opposite. However most of the times the wind driven current will be stronger than the tidal current in the surf area. The wind driven current can push you in the neck of a rip if you are bathing on a sandbar just beside the neck.
It is obvious that this current is very dangerous at groyns.
The Dutch word for this type of current is zoper.