示例#1
0
 $usuario = new usuarios($id);
 // the object $usuario have a property for each field of the table usuarios.
 if (!$pass->check($usuario->pass_usuario)) {
     throw new exception('La contraseña no es valida');
 }
 // this construct an object of $_SESSION var
 $session = new sessionVar('loggued');
 // change the value to true
 $session->set(true);
 // make other object of $_SESSION but this time for $_SESSION['token']
 $token = new sessionVar('token');
 // call to user defined function
 $ht = csrf_token();
 // change value to $_SESSION
 $token->set($ht);
 $idSess = new sessionVar('id');
 $idSess->set($id);
 // tenemos un plan asignado?
 if ($usuario->plan_usuario > 0) {
     // class _date is from the framework.
     $date = new _date();
     if ($usuario->fecha_pago_usuario >= $date->count()) {
         // redirect using force header('location: '.$param1);
         _::redirect('/' . $ht . '/home.html', false);
     } else {
         // sin pagar
         _::redirect('/' . $ht . '/pagar.html', false);
     }
 } else {
     _::redirect('/' . $ht . '/new_plan.html', false);
 }
示例#2
0
 $example = new postVar('example');
 // but if you make new object for post, get, request, session, cookie vars, you making duplicate objects.
 // we strongly recommend don't make more objects, is a lost of resources innecesary, use _::$post property.
 // now, the others objects, add new options:
 // this is a array of session vars
 _::$session;
 $object = _::$session['example'];
 // this have functions of getVar, postVar, etc.
 // and new functions:
 $object->destroy();
 // unset session['example']
 $object->set('new value');
 // session['example'] = 'new value';
 // if isn't exist and you need make new use new sessionVar('name');
 if (!isset(_::$session['example'])) {
     $object = new sessionVar('example');
     $object->set('the value');
 }
 // cookie class work equal to session but it has an exception,
 // set function add second parametter to set lifetime of the cookie:
 if (!isset(_::$cookie['example'])) {
     $object = new cookieVar('example');
     $lifetime = new _date();
     $object->set('the value', $lifetime->hours(10));
 }
 // to set lifetime you need use TIMESTAMP generated by _date class
 $example = new _date();
 // this represents now
 $example->hours(10);
 // now, $example represent now+10 hours
 $example->hours(10)->hours(10);