ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

set, display, and unset session flashdata

August 19, 2009 5:57am

Subscribe [1]
  • #1 / Aug 19, 2009 5:57am

    ranjitbd

    31 posts

    //question 1
    //for set the session
    $_SESSION[‘feedback’] = ‘Feedback send successfully’;

    //for viewing as well as checking the session and unset the session

    <?php
            if(isset($_SESSION[‘feedback’]))
            {
    echo $_SESSION['feedback'];
    unset($_SESSION['feedback']);
    }
    ?>

    //if i use accordingly ur suggestion
    $this->session->set_flashdata(‘feedback’, ‘Message’);

    //then what to do for viewing as well as checking the session and unset the session:
    //my wild guess is:
      if(isset($this->session->set_flashdata(‘feedback’)))
            {
    echo $this->session->set_flashdata(‘feedback’);
              unset($this->session->set_flashdata(‘feedback’));
            }
    //will it work? please describe with code as i am new to CI

    //question 2
    //can i set more index and value in set_flashdata like
    $this->session->set_flashdata(‘feedback’=>‘Message’, ‘comments’=>‘thanks for ur feedback’);

  • #2 / Aug 19, 2009 6:32am

    Dam1an

    2385 posts

    Firstly, this doesn’t belong in the lounger, as it’s actually code stuff 😉
    Secondly, a good place to answer your questions is the user guide, have you read it?
    Thirdly, Use [ code ] blocks in future!

    And finallly on to your questions
    With flashdata, and session data in general, you don’t need to check if it’s set, as if you call a key which doesn’t exist, it will return false
    And with flashdata, the whole point of it is you don’t need to worry about unsetting it, as it will expire after one page

    And as for the second Q, you can either call set_flashdata multiple times passing the key/value pairs, or pass it an array (it’s all covered in the user guide)

  • #3 / Aug 27, 2009 4:06am

    ranjitbd

    31 posts

    //what do u mean by the following line

    Thirdly, Use [ code ] blocks in future!

  • #4 / Aug 27, 2009 4:55am

    Dam1an

    2385 posts

    //what do u mean by the following line

    Thirdly, Use [ code ] blocks in future!

    In pretty much all of your posts I’ve seen, you have a piece of code in there, but it’s as plain text, like so
    <?php
          if(isset($_SESSION[‘feedback’]))
          {
    echo $_SESSION[‘feedback’];
    unset($_SESSION[‘feedback’]);
    }
    ?>

    where as really, you should wrap that text in [code]code goes here[/code] blocks, so it will display like

    <?php
            if(isset($_SESSION[‘feedback’])) 
            {
              echo $_SESSION[‘feedback’];
              unset($_SESSION[‘feedback’]);
            }
    ?>

    Much more readable for every one trying to help you, wouldn’t you say?
    And if you’re using the full reply editor (instead of quick reply) there’s even a ‘code’ button that does the tags for you

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases