Why does identical redirect function give me different behaviour
Do you see the exit
in the CI redirect function? So whenever you use it, it will cause your application to stop processing whatever code you have left. This is the "different" behavior your are experiencing.