Welcome Guest, Not a member yet? Register   Sign In
Unsetting Session In Model
#1

(This post was last modified: 02-20-2015, 06:01 AM by wolfgang1983.)

I have set my auth permissions in sessions.

When I un-select all my permissions and then submit form it clears the database fine.

But need to ask where would be best to add unset($_SESSION['modify']) and unset($_SESSION['access']) need it some where after : "''" so once it clears it from database the unset the two session data.

permission = " . (isset($data['permission']) ? $this->db->escape(serialize($data['permission'])) : "''")) . "

I tried.

permission = " . (isset($data['permission']) ? $this->db->escape(serialize($data['permission'])) : "''", unset($_SESSION['modify']),  unset($_SESSION['access']) )) . "



PHP Code:
public function editUserGroup($user_group_id$data) {
$this->db->query("UPDATE " $this->db->dbprefix "user_group 
SET 
name = " 
$this->db->escape($data['name']) . ", 
permission = " 
. (isset($data['permission']) ? $this->db->escape(serialize($data['permission'])) : "''")) . "
WHERE user_group_id = '" 
. (int)$user_group_id "'
"
);



did not work.

Thanks in advance
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#2

Why not remove it after your query:

PHP Code:
public function editUserGroup($user_group_id$data)
{
    
$this->db->query("UPDATE " $this->db->dbprefix "user_group 
    SET 
    name = " 
$this->db->escape($data['name']) . ", 
    permission = " 
. (isset($data['permission']) ? $this->db->escape(serialize($data['permission'])) : "''")) . "
    WHERE user_group_id = '" 
. (int)$user_group_id "'
    "
);
    if (!isset(
$data['permission'])
    {
        unset(
$_SESSION['modify']);
        unset(
$_SESSION['access']);
    }


Reply
#3

(This post was last modified: 02-20-2015, 07:52 AM by wolfgang1983.)

(02-20-2015, 07:07 AM)Rufnex Wrote: Why not remove it after your query:





PHP Code:
public function editUserGroup($user_group_id$data)
{
    
$this->db->query("UPDATE " $this->db->dbprefix "user_group 
    SET 
    name = " 
$this->db->escape($data['name']) . ", 
    permission = " 
. (isset($data['permission']) ? $this->db->escape(serialize($data['permission'])) : "''")) . "
    WHERE user_group_id = '" 
. (int)$user_group_id "'
    "
);
    if (!isset(
$data['permission'])
    {
        unset(
$_SESSION['modify']);
        unset(
$_SESSION['access']);
    }


Tried it that way but for some reason unset all. need it to try and unset where user_group_id etc. Trying to think best way.

I think now its some thing to do with login.

Because when I login still showing previous data from permissions
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#4

Maybe you have also to clear your session on logout or session timeout.

Reply
#5

(02-20-2015, 07:55 AM)Rufnex Wrote: Maybe you have also to clear your session on logout or session timeout.

I got that part fixed but now issue popped up not sure if should put it on same topic.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#6

unset($_SESSION['var_a'], $_SESSION['var_b']); should work fine
Reply




Theme © iAndrew 2016 - Forum software by © MyBB