Welcome Guest, Not a member yet? Register   Sign In
Duration of setFlashdata
#1

Hi in my controller if several condition are ok i do :

Code:
session()->setFlashdata('success','Password correttamente inviata via Mail');

$data['page_to_redirect'] =  base_url().'/user/login';


in view:

Code:
<?php if (session()->get('success')): ?>

                        <div class='col-md-12 text-center'>

                          <div class='alert alert-success'>

                            <span class=''><?= session()->get('success'); ?></span>

                          </div>

                        </div>           
                     
                      <?php

                          header("Refresh:3 ; url=$page_to_redirect");

                      ?>
<?php endif ?>

When success the page redirect correctly to user login ( that  have the same code on view) but because $page_to_redirect 
are unset i have the error  , session()->setFlashdata  don't work only for one call ?
Reply
#2

Hi, i'm not a expert,

but session()->setFlashdata works for one call in theory (i believe)

I don't quite understand your description of the problem: "but because $page_to_redirect are not defined i have the error " what error ?

If the page redirect correctly, you may put a if condition to the header

but this type of redirection isn't the good type of redirection, in my opinion i would have done diferently
Reply
#3

(11-24-2020, 06:59 AM)neoneeco Wrote: Hi, i'm not a expert,

but session()->setFlashdata works for one call in theory (i believe)

I don't quite understand your description of the problem: "but because $page_to_redirect are not defined i have the error " what error ?

If the page redirect correctly, you may put a if condition to the header

but this type of redirection isn't the good type of redirection, in my opinion i would have done diferently


I use this code to reset password , i insert my email and submit if all it's ok im redirecting to $page_to_redirect   set in controller user/login in this case , but in view user login there is the same code ( to show message and redirect if login it's ok) and because the variable  (session()->get('success') 
are set in the second call also , but in the controller  method user/login $page_to_redirect is not set i have the error . I can solve it with if (isset($page_to_redirect) )  but i dont know why the session variabile is set on redirect...
Reply
#4

Maybe a problem with the headers

seems like to : https://forum.codeigniter.com/thread-77974.html
Reply




Theme © iAndrew 2016 - Forum software by © MyBB