本文整理汇总了PHP中Session::put方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::put方法的具体用法?PHP Session::put怎么用?PHP Session::put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session::put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: poll
public static function poll($polls)
{
$polls = json_decode($polls);
$_results = array();
if (is_array($polls) && count($polls) > 0) {
foreach ($polls as $i => $_poll) {
switch ($_poll->type) {
case "template":
$_results[$_poll->id] = array('type' => 'html', 'args' => Theme::make($_poll->func, array('value' => $_poll->value))->render());
break;
case "plugin":
if ($_poll->func) {
$_results[$_poll->id] = call_user_func($_poll->func, $_poll->value);
}
break;
case "check_logs":
$list = Dashboard::activity();
Session::put('usersonline_lastcheck', time());
$_results[$_poll->id] = array('type' => 'function', 'func' => 'fnUpdateGrowler', 'args' => $list);
break;
}
}
}
return $_results;
}
示例2: dologin
public function dologin()
{
$rules = array('username' => 'required', 'password' => 'required');
$message = array('required' => 'Data :attribute harus diisi', 'min' => 'Data :attribute minimal diisi :min karakter');
$validator = Validator::make(Input::all(), $rules, $message);
if ($validator->fails()) {
return Redirect::to('/')->withErrors($validator)->withInput(Input::except('password'));
} else {
$data = array('username' => Input::get('username'), 'password' => Input::get('password'));
if (Auth::attempt($data)) {
$data = DB::table('user')->select('user_id', 'level_user', 'username')->where('username', '=', Input::get('username'))->first();
//print_r($data);
//echo $data->id_users;
Session::put('user_id', $data->user_id);
Session::put('level', $data->level_user);
Session::put('username', $data->username);
//print_r(Session::all());
return Redirect::to("/admin/beranda");
} else {
Session::flash('messages', '
<div class="alert alert-danger alert-dismissable" >
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>Peringatan...</strong><br>
Username dan password belum terdaftar pada sistem !
</div>
');
return Redirect::to('/')->withInput(Input::except('password'));
}
}
}
示例3: __construct
public function __construct()
{
// Asset::add('jquery.dropdown.css', 'css/jquery.dropdown.css');
Asset::add('bootstrap', 'css/bootstrap.min.css');
Asset::add('bootstrap-responsive', 'css/bootstrap-responsive.css');
Asset::add('common', 'css/common.css');
// Asset::add('style', 'css/style.css');
Asset::add('fontawsome', 'css/fontawesome.css');
Asset::add('flickcss', 'css/flick/jquery-ui-1.10.2.custom.css');
Asset::add('jquery', 'js/jquery-1.9.1.js');
Asset::add('jquery-migrate-1.1.1.js', 'js/jquery-migrate-1.1.1.js');
Asset::add('bootstrap-js', 'js/bootstrap.js');
Asset::add('jqueryui', 'js/jquery-ui-1.10.2.custom.min.js');
Asset::add('jquery.tablesorter.js', 'js/jquery.tablesorter.js');
Asset::add('jquery.tablesorter.pager.js', 'js/jquery.tablesorter.pager.js');
// $files = glob("public/css/pikachoose/*.css", GLOB_BRACE);
// foreach($files as $file)
// {
// Asset::add($file, substr($file, 7));
// }
if (Session::has('id') && Auth::check()) {
$account = Account::find(Session::get('id'));
if ($account->admin == 1) {
Session::put('admin', '1');
} else {
Session::put('admin', '0');
}
if ($account->blocked == 1) {
Session::put('alert', "Your account has been banned. Please contact the admin for more details");
Session::forget('id');
Auth::logout();
} else {
}
}
}
示例4: generate
public static function generate()
{
$token = bin2hex(openssl_random_pseudo_bytes(32));
if (Session::put(Config::get('session_for_csrf_form_token/timestamp_name'), time())) {
return Session::put(Config::get('session_for_csrf_form_token/name'), $token);
}
}
示例5: validateUser
/**
* Validates that no more than 3 failed attempts login to the user sent as a parameter
*
* @param String $email
* @return View
*/
public static function validateUser($email)
{
$count = User::where(['user' => $email])->count();
if ($count > 0) {
if (Session::has($email)) {
$value = Session::get($email);
if ($value >= 2) {
$user = new BlockedUser();
$user->user = $email;
$user->date = new MongoDate();
try {
$user->save();
} catch (MongoDuplicateKeyException $e) {
}
$user = User::first(['user' => $email]);
$info = UserController::getUser($user);
$data = array('name' => strtoupper($info->name));
Mail::send('emails.block-user', $data, function ($message) use($email) {
$message->to($email)->subject(Lang::get('login.blocked_title'));
});
return Redirect::back()->withErrors(array('error' => Lang::get('login.attemp') . ' [' . $email . '] ' . Lang::get('login.blocked') . 30 . Lang::get('login.minute')));
} else {
$value += 1;
Session::put($email, $value);
}
} else {
Session::put($email, 1);
}
}
return Redirect::back()->withErrors(array('error' => Lang::get('login.invalid_user')));
}
示例6: registerUser
/**
* Invokes the user registration on WS.
*
* @return response
* @throws Exception in case of WS error
*/
public function registerUser()
{
try {
$userService = new SoapClient(Config::get('wsdl.user'));
$user = new UserModel(Input::all());
$array = array("user" => $user, "password" => Input::get('password'), "invitationCode" => Input::get('code'));
if (Input::get('ref')) {
$array['referrerId'] = Input::get('ref');
}
$result = $userService->registerUser($array);
$authService = new SoapClient(Config::get('wsdl.auth'));
$token = $authService->authenticateEmail(array("email" => Input::get('email'), "password" => Input::get('password'), "userAgent" => NULL));
ini_set('soap.wsdl_cache_enabled', '0');
ini_set('user_agent', "PHP-SOAP/" . PHP_VERSION . "\r\n" . "AuthToken: " . $token->AuthToken);
Session::put('user.token', $token);
try {
$userService = new SoapClient(Config::get('wsdl.user'));
$result = $userService->getUserByEmail(array("email" => Input::get('email')));
$user = $result->user;
/* if ($user -> businessAccount == true) {
if (isset($user -> addresses) && is_object($user -> addresses)) {
$user -> addresses = array($user -> addresses);
}
} */
Session::put('user.data', $user);
return array('success' => true);
} catch (InnerException $ex) {
//throw new Exception($ex -> faultstring);
return array('success' => false, 'faultstring' => $ex->faultstring);
}
} catch (Exception $ex) {
return array('success' => false, 'faultstring' => $ex->faultstring);
}
}
示例7: generateOTP
private function generateOTP()
{
function generatePassword($length, $strength)
{
$vowels = 'aeuy';
$consonants = 'bdghjmnpqrstvz';
if ($strength & 1) {
$consonants .= 'BDGHJLMNPQRSTVWXZ';
}
if ($strength & 2) {
$vowels .= "AEUY";
}
if ($strength & 4) {
$consonants .= '23456789';
}
if ($strength & 8) {
$consonants .= '@#$%';
}
$password = '';
$alt = time() % 2;
for ($i = 0; $i < $length; $i++) {
if ($alt == 1) {
$password .= $consonants[rand() % strlen($consonants)];
$alt = 0;
} else {
$password .= $vowels[rand() % strlen($vowels)];
$alt = 1;
}
}
return $password;
}
$this->_CODE = generatePassword(8, 4);
Session::put('OTPCode', $this->_CODE);
}
示例8: get_instagram
public function get_instagram()
{
// make sure user is logged in
if (!Auth::user()) {
return Redirect::to('/')->withInput()->withErrors('You must be logged in to access the Instagram panel.');
}
// configure the API values
$auth_config = array('client_id' => CLIENT_ID, 'client_secret' => CLIENT_SECRET, 'redirect_uri' => REDIRECT_URI);
// create a new Auth object using the config values
$auth = new Instagram\Auth($auth_config);
// authorize app if not already authorized
if (!Input::get('code')) {
$auth->authorize();
}
// get the code value returned from Instagram
$code = Input::get('code');
$title = 'ImgHost - Instagram';
// save the access token if not already saved
if (!Session::get('instagram_access_token')) {
Session::put('instagram_access_token', $auth->getAccessToken($code));
}
// create a new Instagram object
$instagram = new Instagram\Instagram();
// set the access token on the newly created Instagram object
$instagram->setAccessToken(Session::get('instagram_access_token'));
// get the ID of the authorized user
$current_user = $instagram->getCurrentUser();
// access the media of the authorized user
$media = $current_user->getMedia();
$db_images = DB::table('images')->get();
return View::make('instagram')->with('title', $title)->with('instagram_images', $media)->with('db_images', $db_images);
}
示例9: post_profile
public function post_profile($table, $col_name, $type)
{
$this->object = database::get_instance();
$users = DB::table('users_login')->orderBy('id', 'desc')->first();
$stu_id = $users->user_session;
$id = $this->object->view($table, "where_pluck", $col_name, '=', $stu_id, 'id');
$profile_image = $this->object->view($table, "where_pluck", 'id', '=', $id, 'profile_image');
Session::put('table', $table);
if (Auth::attempt(array('password' => Input::get('old_pass')))) {
if (Input::get('new_pass') == Input::get('pass_confirm')) {
$this->add_file = $this->object->upload_file('profile_images', $table, 'upload', 'profile_image', "update", 'id', $id, $profile_image);
$val = array('password' => Hash::make(Input::get('new_pass')));
$this->object->update($table, 'id', $id, $val);
} else {
$return = Redirect::to('profile=' . $type)->with('exists', 'Please Enter Correct new password');
}
} else {
$return = Redirect::to('profile=' . $type)->with('exists', 'Please Enter Correct Old password');
}
if ($this->add_file) {
$return = Redirect::to('profile=' . $type)->with('success', 'You successfully Update Your Profile.');
} else {
$return = Redirect::to('profile=' . $type)->with('exists', 'Please Select a file');
}
return $return;
}
示例10: login
/**
* @param $code
* @return string
*/
public function login($code)
{
$this->client->authenticate($code);
$token = $this->client->getAccessToken();
\Session::put('token', $token);
return $token;
}
示例11: update
public function update($id, $quantity)
{
$cart = \Session::get('cart');
$cart[$id]->quantity = $quantity;
\Session::put('cart', $cart);
return redirect()->route('cart-show');
}
示例12: Authenticate
public function Authenticate($Username = false, $Password = false, $Remember = false)
{
if ($Username !== false && $Password !== false) {
//Confirm Input
$UserData = DB::getInstance()->table("Users")->where("Username", $Username)->get(1)[0];
$HashedPassAttempt = Hash::make(Input::get("Password"), $UserData->Salt);
if ($HashedPassAttempt == $UserData->Password) {
Session::put("UserID", $UserData->UserID);
if ($Remember == 'on') {
//Was Remember Me Checkbox ticked?
$hashCheck = DB::getInstance()->table("user_sessions")->where('user_id', $UserData->UserID)->get();
//Check for existing session
if (count($hashCheck) == 0) {
//If there is not an existing hash
$hash = Hash::unique();
DB::getInstance()->table('user_sessions')->insert(array('user_id' => $UserData->UserID, 'hash' => $hash));
} else {
//use existing hash if found
$hash = $hashCheck[0]->hash;
}
$Cookie = Cookie::put(Config::get("remember/cookie_name"), $hash, Config::get("remember/cookie_expiry"));
//Set cookie
}
return $this->form($UserData->UserID);
//Return User MetaTable
} else {
throw new Exception('Invalid Username or Password');
}
} else {
throw new Exception('Invalid Username or Password');
}
return false;
}
示例13: login
/**
* Display customer login screen.
*
* @return Response
*/
public function login()
{
if (Auth::check()) {
return Redirect::route('profile');
} elseif (Request::isMethod('post')) {
$loginValidator = Validator::make(Input::all(), array('email' => 'required', 'password' => 'required'));
if ($loginValidator->passes()) {
$inputCredentials = array('email' => Input::get('email'), 'password' => Input::get('password'));
if (Auth::attempt($inputCredentials)) {
$customer = Customer::find(Auth::id());
if ($customer->admin_ind) {
Session::put('AdminUser', TRUE);
}
if (is_null($customer->address)) {
// If customer does not have address, redirect to create address.
return Redirect::route('customer.address.create', Auth::id())->with('message', 'No address found for account. Please enter a valid address.');
}
return Redirect::intended('profile')->with('message', 'Login successful.');
}
return Redirect::back()->withInput()->withErrors(array('password' => array('Credentials invalid.')));
} else {
return Redirect::back()->withInput()->withErrors($loginValidator);
}
}
$this->layout->content = View::make('customers.login');
}
示例14: getIndex
public function getIndex()
{
Session::put('flag', 11);
$dados["status_notificacao"] = 2;
$result = DB::table('pedidos')->where("status_notificacao", 1)->update($dados);
return View::make("pedidos.pedidos");
}
示例15: testClearUserAddSelftProfile
public function testClearUserAddSelftProfile()
{
\Session::put('Giftertipster\\Service\\Add\\AddProfileMgr.user_add_self_profile', 'test');
assertThat(\Session::has('Giftertipster\\Service\\Add\\AddProfileMgr.user_add_self_profile'), identicalTo(true));
$this->add_profile_mgr->clearUserAddSelfProfile();
assertThat(\Session::has('Giftertipster\\Service\\Add\\AddProfileMgr.user_add_self_profile'), identicalTo(false));
}