0

Is it possible to pass a query string through base_url() function in codeigniter?

I would like to add ?login=1 to the base url which user arrives at after being redirected in this function:

redirect(base_url());

1 Answer 1

2

This is done with simple string concatenation.

redirect(base_url().'?login=1');

and as per the documentation, you can indeed pass a string into the base_url() function:

redirect(base_url('?login=1'));

Although it isn't designed for this purpose - it's supposed to be used for segments so functionality with a query string passed into the function isn't guaranteed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.