I think it might be possible to implement such a scheme, but I don't think it would be remotely practical. There are a number of problems. I'll fill in some more detail, and some potential ways around these problems.
1. Required strength of magnet. You need the strength of the magnets to be enough such that the energy of the two magnets at the minimum separation is equal to the initial kinetic energy of the cars. If I idealize the magnets as a current loop, I get a maximum magnetic field of several T required to stop two 1000kg cars going 30mph relative to each other. (In general, the required field scales linearly with stopping velocity, since both dipole-dipole and kinetic energy are quadratic in magnetic moment and velocity, respectively.) Such magnetic fields can be generated by superconducting solenoids, as in an MRI machine. (But you could have a much smaller-sized magnet here than in an MRI machine since you don't need to put a person inside it.) The nice thing about this is that you don't need to carry the power source with you. You can just ramp up the magnet at home, plugged into the wall, and then since it is superconducting, you can disconnect the power source and the magnet will stay on. The disadvantage is that you need to keep the magnet immersed in liquid helium, and superconducting magnets don't take well to being jostled around while they are running (as they would be in a moving car, especially one that is colliding with another car). The issue here is that a sudden shock to a part of the magnet can cause a bit of the superconductor to become non-superconducting, which generates a bit of heat, which causes the whole magnet to become nonsuperconducting, which generates a large amount of heat, instantly vaporizing the liquid helium in a possibly explosive manner (called a "quench").
2. Unintentional attraction of ferromagnetic metals. If you have been around an MRI machine, you know that care must be taken not to get any ferromagnetic metals near the machine, or they can be sucked into the machine in a costly and dangerous way. We would have the same problem here. To solve this problem, I could imagine a system that would rapidly move the magnet around. For example, the magnet could normally be mounted a few meters in the air, and then could be quickly dropped down to car level when an accident were imminent. Since the external off-axis field of a solenoid is pretty small, things at ground level shouldn't be affected too much. You could get into trouble with bridges though...
3. Orientation of the magnet with respect to the other car. You would certainly need to have the polarity of the magnets on each car oriented correctly so as to repel each other, and not attract. And since you want to protect against both head-on and rear-end collisions, you need to determine this on the fly. You also need to have the magnets lined up correctly so that the repulsive force slows the cars down and doesn't just fling them to the side or upwards. To get around this problem, the mechanism that lowers the magnet down to car level could also flip the magnet end-for-end, and position it correctly, by using magnetic field sensors to determine the polarity and position of the other car's magnet. Obviously there would have to be some protocol to ensure that both cars work together to get the magnets aligned.
4. Stopping time. There is still the issue that regardless of how you stop the car, the energy has to go somewhere. The advantage of the magnet scheme is that it lowers the kinetic energy slowly, for less of a shock to the car and passengers. However, since the repelling force of two opposing magnets goes like 1/r^4, most of the deceleration will happen as the two cars get close. But it is still better than having two completely rigid cars collide.
A better solution would be to simply attach a big metal spring to the front of the car. Then the force goes like (r-r_0)^2 (where r_0 is the extended length of the spring), and is zero for r>r_0. This allows the same amount of kinetic energy to be extracted more gradually than with magnets. It also solves the problem of unwanted attraction or repulsion, since the force is zero for r>r_0 (the spring only repels things that it is touching). Still, a problem with the spring is that after you collide, the springs would expand again and fling you back into motion, which may be undesirable.
A better solution still would be, instead of a spring, have a "one-time" spring that just compresses, but doesn't rebound. That is, a metal structure that just takes energy to crunch down and then stays crunched. Fortunately, this is exactly what the ends of cars are designed to do. Pretty clever of them!More questions on Physics: