本文整理汇总了PHP中Illuminate\Support\Facades\Session类的典型用法代码示例。如果您正苦于以下问题:PHP Session类的具体用法?PHP Session怎么用?PHP Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($method, array $fields = [], array $options = [], $url = null, $assoc = false)
{
if ($url) {
$this->url = $url;
}
$this->url .= $method;
$this->ch = curl_init($this->url);
if (!$this->ch) {
throw new Exception('Curl initialisation failed!');
}
$this->defaultFields['access_token'] = Session::get('vk_token');
$options[CURLOPT_POSTFIELDS] = http_build_query(array_replace($this->defaultFields, $fields));
$this->options = array_replace($this->defaults, $options);
if (!curl_setopt_array($this->ch, $this->options)) {
throw new Exception('Curl options setting failed!');
}
$this->results = json_decode(curl_exec($this->ch), $assoc);
if (!$this->results) {
throw new Exception('Curl exec failed');
}
if (isset($this->results->error)) {
throw new Exception($this->results->error->error_code . ': ' . $this->results->error->error_msg, $this->results->error->error_code);
}
curl_close($this->ch);
}
示例2: handle
/**
* Handle an incoming request and check for playerId in the session
* If it cannot be found it will redirect the the URL in the config
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Session::has('email')) {
return $next($request);
}
return redirect('/' . config('sol.loginUrl', 'sollogin'));
}
示例3: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$contact = Contact::findOrFail($id);
$contact->delete();
Session::flash('message', 'Successfully Deleted your Data!');
return redirect()->back();
}
示例4: index
/**
* Redirect to the homepage.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
Session::flash('', '');
// work around laravel bug if there is no session yet
Session::reflash();
return Redirect::to($this->path);
}
示例5: store
public function store(LocationRequest $request)
{
$location = Location::create($request->all());
Session::flash('success', true);
Session::flash('message', 'Aðgerð tókst: Ný staðsetning');
return Redirect::back();
}
示例6: showNews
/**
* @return mixed
*/
public function showNews()
{
$slug = Request::segment(2);
$news_title = "Not active";
$news_text = "Either this news item is not active, or it does not exist";
$active = 1;
$news_id = 0;
$results = DB::table('news')->where('slug', '=', $slug)->get();
foreach ($results as $result) {
$active = $result->active;
if ($active > 0 || Auth::check() && Auth::user()->hasRole('news')) {
if (Session::get('lang') == null || Session::get('lang') == "en") {
$news_title = $result->title;
$news_text = $result->news_text;
$news_id = $result->id;
} else {
$news_title = $result->title_fr;
$news_text = $result->news_text_fr;
$news_id = $result->id;
}
$news_image = $result->image;
$news_date = $result->news_date;
}
}
return View::make('public.news')->with('news_title', $news_title)->with('news_text', $news_text)->with('page_content', $news_text)->with('active', $active)->with('news_id', $news_id)->with('news_date', $news_date)->with('news_image', $news_image)->with('menu', $this->menu)->with('page_category_id', 0)->with('page_title', $news_title);
}
示例7: destroy
public function destroy($id)
{
$asignaturas = Asignatura::find($id);
$asignaturas->delete();
Session::flash('message', 'La asignatura ' . $asignaturas->nombre . ' fue eliminada');
return redirect()->route('Encargado.asignaturas.index');
}
示例8: set
public function set($key, $value)
{
if (!Session::has($this->namespace)) {
$this->clear();
}
Session::put($this->namespace . '.' . $key, $value);
}
示例9: update
public function update($id, ClanakRequest $request)
{
$clanak = Article::findOrFail($id);
$clanak->update($request->all());
Session::flash('flash_message', 'Uspjesno ste izmjenili clanak');
return redirect('clanak');
}
示例10: update
public function update()
{
$btnStatus = Input::get('btn_sta');
$inputs = Input::get('check');
switch ($btnStatus[0]) {
case 1:
foreach ($inputs as $key => $id) {
DB::table('users')->where('id', $id)->delete();
}
Session::flash('flash_message', "Sukses Menghapus Data !!");
break;
case 2:
foreach ($inputs as $key => $id) {
DB::table('users')->where('id', $id)->update(['hak_akses' => "2"]);
}
Session::flash('flash_message', "Sukses Memperbaharui Status !!");
break;
case 3:
foreach ($inputs as $key => $id) {
DB::table('users')->where('id', $id)->update(['hak_akses' => "3"]);
}
Session::flash('flash_message', "Sukses Memperbaharui Status !!");
break;
default:
break;
}
return redirect('users');
}
示例11: markAcceptance
public function markAcceptance($policyCode, $userUid)
{
// get inputs
//
$policy = Policy::where('policy_code', '=', $policyCode)->first();
$user = User::getIndex($userUid);
$acceptFlag = Input::has('accept_flag');
// check inputs
//
if (!$user || !$policy || !$acceptFlag) {
return Response::make('Invalid input.', 404);
}
// check privileges
//
if (!$user->isAdmin() && $user->user_uid != Session::get('user_uid')) {
return Response::make('Insufficient privileges to mark policy acceptance.', 401);
}
// get or create new user policy
//
$userPolicy = UserPolicy::where('user_uid', '=', $userUid)->where('policy_code', '=', $policyCode)->first();
if (!$userPolicy) {
$userPolicy = new UserPolicy(array('user_policy_uid' => GUID::create(), 'user_uid' => $userUid, 'policy_code' => $policyCode));
}
$userPolicy->accept_flag = $acceptFlag;
$userPolicy->save();
return $userPolicy;
}
示例12: postProcess
public function postProcess(LoginRequest $request)
{
$username = $request->input('username');
$password = $request->input('password');
$user = DB::table('users')->where('username', $username)->first();
if (isset($user)) {
Session::put('username', $user->username);
Session::put('name', $user->name);
Session::put('surname', $user->surname);
}
if (Auth::attempt(['username' => $username, 'password' => $password, 'type' => 'patient'], $request->has('remember'))) {
return redirect()->intended('/login/patient');
}
if (Auth::attempt(['username' => $username, 'password' => $password, 'type' => 'doctor'], $request->has('remember'))) {
return redirect()->intended('/login/doctor');
}
if (Auth::attempt(['username' => $username, 'password' => $password, 'type' => 'nurse'], $request->has('remember'))) {
return redirect()->intended('/login/nurse');
}
if (Auth::attempt(['username' => $username, 'password' => $password, 'type' => 'pharmacist'], $request->has('remember'))) {
return redirect()->intended('/login/pharmacist');
}
if (Auth::attempt(['username' => $username, 'password' => $password, 'type' => 'officer'], $request->has('remember'))) {
return redirect()->intended('/login/officer');
}
return redirect()->back()->with('message', "ขออภัย username หรือ password ไม่ถูกต้อง\nกรุณาลองใหม่");
}
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string $l
* @return mixed
*/
public function handle($request, Closure $next)
{
//Session::flush();
if (!Session::has('locale')) {
/**
* Get the browser local code and lang code.
*/
$localCode = $request->getPreferredLanguage();
$localLang = substr($localCode, 0, 2);
if (in_array($localLang, $this->lang)) {
Session::set('locale', $localLang);
} else {
Session::set('locale', Config::get('app.locale'));
}
}
/**
* Set the local config.
*/
App::setLocale(Session::get('locale'));
Config::set('app.locale', Session::get('locale'));
/**
* Share variables in view.
*/
if (Config::get('app.locale') == 'fr') {
View::share(['lang' => 'fr', 'langreverse' => 'en']);
} else {
View::share(['lang' => 'en', 'langreverse' => 'fr']);
}
return $next($request);
}
示例14: run
/**
* Run the application and save headers.
* The response is up to WordPress
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @return void
*/
public function run(SymfonyRequest $request = null)
{
/**
* On testing environment the WordPress helpers
* will not have context. So we stop here.
*/
if (defined('WELOQUENT_TEST_ENV') && WELOQUENT_TEST_ENV) {
return;
}
$request = $request ?: $this['request'];
$response = with($stack = $this->getStackedClient())->handle($request);
// just set headers, but the content
if (!is_admin()) {
$response->sendHeaders();
}
if ('cli' !== PHP_SAPI) {
$response::closeOutputBuffers(0, false);
}
/**
* Save the session data until the application dies
*/
add_action('wp_footer', function () use($stack, $request, $response) {
$stack->terminate($request, $response);
Session::save('wp_footer');
});
}
示例15: store
public function store(Request $request)
{
//dd('jajaja');
$file = $request->file('file');
//obtenemos el campo file obtenido por el formulario
$nombre = $file->getClientOriginalName();
//indicamos que queremos guardar un nuevo archivo en el disco local
\Storage::disk('local')->put($nombre, \File::get($file));
\Excel::load('/storage/public/files/' . $nombre, function ($archivo) use(&$falla) {
$result = $archivo->get();
//leer todas las filas del archivo
foreach ($result as $key => $value) {
$var = new Periodo();
$datos = ['bloque' => $value->bloque, 'inicio' => $value->inicio, 'fin' => $value->fin];
$validator = Validator::make($datos, Periodo::storeRules());
if ($validator->fails()) {
Session::flash('message', 'Los Periodos ya existen o el archivo ingresado no es valido');
$falla = true;
} else {
$var->fill($datos);
$var->save();
}
}
})->get();
if ($falla) {
// Fallo la validacion de algun campus, retornar al index con mensaje
return redirect()->route('Administrador.periodos.index');
}
\Storage::delete($nombre);
Session::flash('message', 'Los Periodos fueron agregados exitosamente!');
return redirect()->route('Administrador.periodos.index');
}