Sessiyalarni boshqarish. Reja: sessiyalarni boshqarish


Download 25.56 Kb.
bet1/2
Sana20.12.2022
Hajmi25.56 Kb.
#1035701
  1   2
Bog'liq
SESSIYALARNI BOSHQARISH.

SESSIYALARNI BOSHQARISH.

REJA:

  1. SESSIYALARNI BOSHQARISH.


  2. NAMESPACE APP\HTTP\MIDDLEWARE;





1.Sessiyalarni boshqarish.



Laravelda marshrutlar uchun sessiyalarni taqiqlash (maxsus so'rovni seansni boshqarish)


Android-ilovalarim uchun API-ni qurish va REDIS-ga o'rnatilgan standart sessiya drayverini ishlataman.
Men yaxshi maqola topdim, bu yerda http://dor.ky/laravel-prevent-sessions maqsadiga xizmat qiladigan qanday-marshrutlar orqali-a-filtr/.
Ammo urlni urganimda, u ham redislarga o'tadi va bo'sh kalitni yaratadi. Endi men redisda bo'sh sessiya tugmachalarini yaratishdan qochishni xohlayman. Ideal holda, u rediska urmasligi kerak. Buni qanday qilishim mumkin?
Sessiyalarni faqat muayyan marshrutlar uchun (yoki muayyan marshrutlar uchun o'chirib qo'yish) yaratadigan qilib sozlashimiz mumkinmi?
Muayyan foydalanish holatlarida ko'proq narsani tushuntirishi mumkin, iltimos menga xabar bering.
Laravel 5-da intervalli dastur yordamida, albatta, oson, bir sessiya o'tkazmaslik uchun API kaliti bilan har qanday so'rov kerak edi va shunchaki qildim:

namespace App\Http\Middleware;

use Closure;
use Illuminate\Session\Middleware\StartSession as BaseStartSession;

class StartSession extends BaseStartSession


{ /**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if(\Request::has('api_key'))
{
\Config::set('session.driver', 'array');
}
return parent::handle($request, $next);
}
}
Bundan tashqari, SessionServiceProvider dasturini quyidagi kabi kengaytirishingiz kerak bo'ladi:

use Illuminate\Session\SessionServiceProvider as BaseSessionServiceProvider;

class SessionServiceProvider extends BaseSessionServiceProvider
{
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->registerSessionManager();

$this->registerSessionDriver();

$this->app->singleton('App\Http\Middleware\StartSession');
}
}
config/app.php provayderlari ostida joylashtiring:

'App\Providers\SessionServiceProvider',


Bundan tashqari, $ middlewareGroups bo'limida App/Http/Kernel.php bo'limida o'zingizning yadro faylida o'zgartirishingiz kerak bo'ladi: \ Illuminate \ Session \ Middleware \ StartSession :: class, kabi yangi sinfga \ App \ Http \ Middleware \ StartSession :: class, .

8
0
malhal


Savolga javob
3i8/8/2015ubэрталабn2015. 8 август 2015 в 11:15
Batafsil
Bunga erishishning eng oddiy yo'li - Illuminate \ Session \ Middleware \ StartSession ning subclasses va kernel.php da ishlatiladigan sinfni o'z AppStartSession katmanini yaratishdir. Subclassda bekor qilishingiz kerak bo'lgan yagona usul sessionConfigured () ga ruxsat berish uchun sessiya yoki ota-ona: sessionConfigured () ni o'chirib qo'yishingiz mumkin.

Download 25.56 Kb.

Do'stlaringiz bilan baham:
  1   2




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling