<?php
/**
 * Created by PhpStorm.
 * User: Mehmet
 * Date: 23.3.2016
 * Time: 11:59
 */

class session {

    public $mysession;

    public function __construct(){

        ini_set('session.save_handler', 'files');
       // ini_set(' session.save_path',__DIR__.'/cocok');
        session_save_path(__DIR__ . '/coook');
        session_start();
    }

    public function Add(array $data=array()){

        if(is_array($data) && !empty($data)){

            $data   =   array_map('trim',$data);

                foreach($data as $key => $value){
                    $_SESSION[$key]     =   $value;
                }
            return true;
        }else{
            return false;
        }
    }

    public function SessionDestroy(){
        session_destroy();

    }

    public function userdata($key){
         return $_SESSION[$key] ? $_SESSION[$key] : false;

    }

    public function all_userdata(){
        return $_SESSION;
    }

    public function session_unset($key){
            if(!empty($key) && $_SESSION[$key]){
                unset($_SESSION[$key]);
                return true;
            }else{
                return false;
            }
    }
}