Welcome Guest, Not a member yet? Register   Sign In
session problem
#11

[eluser]paulon[/eluser]
ok now im confused.. i used the callback function from form_validation, the same thing happen code is ok everythings working fine but still browser offering to remember a password even thought the login fails.... =(

Code:
function log_in_credential()
    {
        $this->load->library('form_validation');
        $this->form_validation->set_rules('username','Username','trim|required');
        $this->form_validation->set_rules('password','Password','trim|required|callback_checkuserpassword');
        $this->form_validation->run();                                            
        $this->index();
    }
    
    function checkuserpassword($strpass){
        $this->form_validation->set_message('checkuserpassword', "Username or Password invalid.");
        $this->db->where('username', $this->input->post('username'));
        $this->db->where('password', $strpass);
        $query = $this->db->get('members');
        
        if($query->num_rows > 0){            
            $row = $query->row();        
            $data = array(
                'username' => $this->input->post('username'),
                'member_id' => $row->member_id,
                'is_logged_in' => true,
                'login_time' => date('Y-m-d H:i:s'),
                'last_msg_recieved_lobby' =>  date('Y-m-d H:i:s'),
                'accountstatus' => $row->accountstatus                
            );
            $this->session->set_userdata($data);            
            return true;
            
        }else{                
            return false;
        }
    }
#12

[eluser]paulon[/eluser]
im stuck.... =(
#13

[eluser]paulon[/eluser]
i continue to remember the password and i clear the private data from firefox 3.5.6,
now it don't offer to remember any password, but the problem become reverse, in login fails the remember password is gone which is right way, but in logged in success their isn't offer to remember anypassord..

=(

does my computer have a virus or i missing something??
#14

[eluser]CI_avatar[/eluser]
@paulon
i dont know the problem but it there something lacking
in setting your session. You've missed to set the default session values.

Code:
$data = array
(
     'session_id'    => random hash,
     'ip_address'    => 'string - user IP address',
     'user_agent'    => 'string - user agent data',
     'last_activity' => timestamp
);
$this->session->set_userdata($data);

then you just add your own session values entities.
Code:
$data = array(
     'username' => $this->input->post('username'),
     'member_id' => $row->member_id,
     'is_logged_in' => true,
     'login_time' => date('Y-m-d H:i:s'),
     'last_msg_recieved_lobby' =>  date('Y-m-d H:i:s'),
     'accountstatus' => $row->accountstatus                
);
$this->session->set_userdata($data);

I hope it will work...
#15

[eluser]paulon[/eluser]
[quote author="CI_avatar" date="1261378501"]@paulon
i dont know the problem but it there something lacking
in setting your session. You've missed to set the default session values.

Code:
$data = array
(
     'session_id'    => random hash,
     'ip_address'    => 'string - user IP address',
     'user_agent'    => 'string - user agent data',
     'last_activity' => timestamp
);
$this->session->set_userdata($data);

then you just add your own session values entities.
Code:
$data = array(
     'username' => $this->input->post('username'),
     'member_id' => $row->member_id,
     'is_logged_in' => true,
     'login_time' => date('Y-m-d H:i:s'),
     'last_msg_recieved_lobby' =>  date('Y-m-d H:i:s'),
     'accountstatus' => $row->accountstatus                
);
$this->session->set_userdata($data);

I hope it will work...[/quote]


does setting this required?

$data = array
(
'session_id' => random hash,
'ip_address' => 'string - user IP address',
'user_agent' => 'string - user agent data',
'last_activity' => timestamp
);
$this->session->set_userdata($data);
#16

[eluser]paulon[/eluser]
i got another question.

how is it that my that my input password always remember my password?

when i logout i call my function logout

Code:
function logout()
    {
        $data = array(
            'username' =>'',
            'member_id' => 0,
            'is_logged_in' => false,
            'login_time' => date('Y-m-d H:i:s'),
            'last_msg_recieved_lobby' =>  date('Y-m-d H:i:s'),
            'accountstatus' => ''                
        );
        $this->session->set_userdata($data);
        $this->session->set_flashdata('msg', 'Succesfully signed out.');
        $this->session->sess_destroy();        
        redirect('generals/index');
    }
or
Code:
function logout()
    {
        $this->session->sess_destroy();        
        redirect('generals/index');
    }

either one of this keeps remembering my password when i type the same username

regards to the pinoy CI lover.... ^_^ pinoy here..
#17

[eluser]CI_avatar[/eluser]
Sorry for the wrong response, i found out that it is not necessary to set

$data = array
(
‘session_id’ => random hash,
‘ip_address’ => ‘string - user IP address’,
‘user_agent’ => ‘string - user agent data’,
‘last_activity’ => timestamp
);
$this->session->set_userdata($data);

...

With your password remembering problem? are you using firefox? maybe you have set to remember password with
your browser. please disable remember password. does password remembering happen in IE?
#18

[eluser]paulon[/eluser]
IE does not remember any password.. so i guess i just did remember it in firefox.. that solves the problem..

since your active right now, i got other question.
1. how am i going to prevent php script from calling direct from the browser?

what happens here is that i got some ajax that calls the script but i don't wan't that script to be call direct in the browser..

hope your getting what i have in mind.. ^_^
#19

[eluser]paulon[/eluser]
or, if i put that script in model folder should that protect it? does that prevent from calling direct from the browser?
#20

[eluser]CI_avatar[/eluser]
@paulon

It is a hard problem to discuss it here. but i'll try to explain it.
if your are in your main.php (main.php is a controller) and you are trying to call processor.php (processor.php is a controller) here is the sample code in jquery.

Code:
$(document).ready(function(){

$(function(){
    $(".submit-btn").click(function(){
      $.post('index.php?c=processor', { //or $.post('index.php/processor'
        //list of post variable follows
        samplevar      : 'addrequisition',
        samplevar2     : $("[name=username]").val()
        //...more variable
      },function(data){
        alert(data); //display the echo from processor.php
                     //If you echo "hello world" in processor.php
                     //and after calling ajax then hello world alerted
                     //it means that you requested the processor.php successfully
                     //note: data variable holds the values echoed from processor.php
      });
});

});

note: main.php includes the jquery and other javascript.




Theme © iAndrew 2016 - Forum software by © MyBB