user1166654
user1166654

Reputation: 53

Check session is set, codeigniter

I have a upload script which post upload lets the user edit the content title for a period of time. It sets the following in the ci_sessions user_data column in the db:

array (
  'user_data' => '',
  'edit' => 
  array (
    'image_id' => 'HF',
    'session_id' => '783c15b057bcd9c19d3fd82f367ee55d',
  ),
)

The problem is my session CHECK code can't find the session:

<?php if ($this->session->userdata('edit') !== FALSE) : ?> 
<?php echo '<!-- session found -->'; ?>
    <?php $session_info = $this->session->userdata('edit'); ?>
    <?php $ids_array = explode(",", $session_info['image_id']); ?>
    <?php foreach ($ids_array as $id): ?>
    <?php 
    if ($id == $alpha_id 
    && 
    $session_info['session_id'] == $this->session->userdata('session_id')) :
    ?> 

The echo on line 2 of that block never gets outputted. Can anyone see what I'm doing wrong? thanks

heres my controller http://pastebin.com/aXeRn1VN

Upvotes: 2

Views: 12952

Answers (1)

Code Prank
Code Prank

Reputation: 4250

Try this

<?php if( $this->session->userdata('edit') ) : ?> 

instead of

<?php if ($this->session->userdata('edit') !== FALSE) : ?> 

Upvotes: 1

Related Questions