Reputation: 103
I have a codeigniter project I am working on. When a certain flashdata gets added the site locks up for no apparent reason. I write some data to my database or remove it. Then according to a success of fail I set some flashdata and redirect to the appropriate page. There a gallery gets loaded in and the associated flashdata gets used. But 75% of the time it locks up for a couple seconds (between 10-15 on local testing).
I figured out it is the flashdata that is the issue and it happens as soon as I add it. Even when I remove the flashdata code out of the view the site locks up. Which by itself is strange to me. Even when it does not get used it locks up sometimes.
view part
<?php if($this->session->flashdata('msg')) : ?>
<div class="alert alert-success" role="alert">
<?php echo $this->session->flashdata('msg'); ?>
</div>
<?php endif; ?>
<?php if($this->session->flashdata('error')) : ?>
<div class="alert alert-danger" role="alert">
<?php echo $this->session->flashdata('error'); ?>
</div>
<?php endif; ?>
The controller code block
public function deleteVisitorLink($gallery_id)
{
if(!$this->gallery_model->removeVisitorLink($gallery_id))
{
$this->logging->Log($this->session->userdata('id'), '550', 'Could not delete the visitor link for gallery ' . $gallery_id);
$this->session->set_flashdata('error','Kon de link niet verwijderen.');
$this->myRedirect();
}
else
{
$this->logging->Log($this->session->userdata('id'), '560', 'Visitor link deleted for gallery ' . $gallery_id);
$this->session->set_flashdata('msg','De bezoekers link is verwijderd.');
}
redirect(base_url() . '/client/' . $gallery_id);
}
The myRedirect() is just a check and a standard redirect to client
I am trying to figure out why it is happening and what I might be able to do to fix this. Any tip or pointer is helpful as I am pretty new to coding.
Upvotes: 0
Views: 41
Reputation: 103
After some great insights by @04FS
I figured the issue light with the unsigning of the flashdata.
So instead i a now using tempdata. And i remove the tempdata at the end of the view.
Upvotes: 0