Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
Codeigniter Redirect to desired url after user login

I have a website with Codeigniter 3 framework.

There is a login page as www.example.com/login

If author login to the panel they are redirecting to main page www.example.com/author/feed.

There are many pages in Author controller such as my-profile, edit-profile, reset-password etc.

If author wants to access www.example.com/author/my-profile they are redirected to www.example.com/login, after login they are redirected to to main page www.example.com/author/feed.

But I want them to redirect to www.example.com/author/my-profile.

What function I need to use in my code??

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can use the helper function redirect(). You can learn more here.

// after login
redirect('/author/my-profile');
over 4 years ago · Santiago Trujillo Report

0

You need to save your desired route in session before redirecting to login page like this:

$this->session->set_userdata('page', base_url('my-profile'));

When a user logs in, you can check if page is stored in session, otherwise redirect to base url:

$pageLink = base_url();               
if ($this->session->userdata('page')) {
    $pageLink = $this->session->userdata('page');
    $this->session->unset_userdata('page');
}

redirect($pageLink);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!