Welcome Guest, Not a member yet? Register   Sign In
session flashdata read write probleme ...
#1

hallow guys. hope you doing good

so my problem is I want to throw toaster message telling users status of last operation like:


Code:
$this->session->set_flashdata('error_message',get_phrase('invalid_login_credentials'));


then i redirect to home page and catch the messages : 


Code:
redirect(site_url('home'), 'refresh');


Code:
<?php if ($this->session->flashdata('error_message') != ""):?>

<script type="text/javascript">

    $(document).ready(function () {
        toastr.error('<?php echo $this->session->flashdata("error_message");?>');

    });
</script>

<?php endif;?>


every thing work fine in xampp localhost. but in live server sometimes the message show sometimes not. after testing and debugging i found that $this->session->flashdata("error_message") is empty when message not show. and i try to use userdata rather flashdata i found that sometimes in first redirect message not shown ( same thing as flashdata ) but in every other refresh message shown in userdata.

is that because session blocking or CodeIgniter problem or maybe slow writing mechanism ?

here my session configuration

Code:
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 259200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 0;
$config['sess_regenerate_destroy'] = FALSE;


pls help me in this.
thanks
Reply
#2

Did you try.

PHP Code:
$session->keepFlashdata(['item1''item2''item3']); 

To see if it needs an extra save call.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

yes, and like i said when i use permanent userdata sometimes the message show in first redirect sometimes not , but when i refresh after first request the message always appear.
Reply
#4

yes, doesn't work
Reply
#5

any help ?
Reply
#6

Your calling JavaScript then your calling toaster which is JavaScript so the flash data
is mostly being destroyed.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

(04-20-2021, 08:40 PM)InsiteFX Wrote: Your calling JavaScript then your calling toaster which is JavaScript so the flash data
is mostly being destroyed.

when i run tests on the problem i fount that in this line 
Code:
<?php if ($this->session->flashdata('error_message') != ""):?>
 
flashdata('error_message') is empty which is before i call JavaScript.
Reply
#8

Then I would report it as a bug.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#9

(04-21-2021, 01:00 PM)InsiteFX Wrote: Then I would report it as a bug.


i think it is slow write read mechanisme because like said it work somtimes and when i use userdata instead of flashdata in first redirect sometimes show somtimes not (empty) like flashdata but after that after each refresh it always show 
how you explain this ?
i try to use sleep before check the session to delay excution but it not work
Reply




Theme © iAndrew 2016 - Forum software by © MyBB