Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6022481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:51:51+00:00 2026-05-23T03:51:51+00:00

I learned about flashdata and decided to use it to display messages based on

  • 0

I learned about flashdata and decided to use it to display messages based on database interactions.

For example if no rows are affected I want to display Post id is invalid or does not exist!

In my model

function delete_post($post_id)
    {
        $this->db->where('user_id', $user_id);
        $this->db->where('post_id', $post_id);
        $this->db->delete('posts'); 

        if ($this->db->affected_rows() == 0) 
        {
            $this->session->set_flashdata('result', 'Post id is invalid or does not exist!');
            redirect('/posts/management');
            return FALSE;
        }
        else
        {

            redirect('/posts/management');
            return TRUE;
        }                   
    }

and in my view

if ($this->session->flashdata('result') != ''): 
    echo $this->session->flashdata('result'); 
endif;

This seems to work fine but there is no example in the CI documentation how to pass flashdata between MVC. I’m concerned.. Am I doing this correctly?

edit: I seem to have left FALSE and TRUE from a prior attempt. I probably won’t need that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:51:52+00:00Added an answer on May 23, 2026 at 3:51 am

    Session data is available anywhere in your application, at any time. Calling it directly from a view file is proper, and so it setting it in a Controller.

    There’s no need at all to pass it as data with $this->load->view() – it’s redundant. Why assign it to the flashdata in the first place in that case?

    The way you’re doing it is correct.

    EDIT: I just saw you are setting it in the Model instead of Controller – which is highly debatable. I would suggest returning a value from your Model call, and setting the message based on it in your Controller instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently learned about CTE's in SQL Server and am attempting to use it
I just learned about jquery's .makeArray and I am trying to use JSON.stringify to
I first learned about Data, context, and interaction (DCI) through this blog post .
I recently learned about strides in the answer to this post , and was
Ever since learned about using event aggregators to publish messages instead of using events
I learned about pystones today and so I decided to see what my various
So far I have learned about generating thread dump and heap dump using jstack
I've just recently learned about friend class concept in C++ (I've googled around for
Recently I learned about Werkzeug's interactive debugger in combination of django_extensions to debug Django
I just posted this question and learned about <see cref=> , however when i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.