Category : session

I have a native PHP app which authentication part is handled. I save the session to data base there. public function write($sessionId, $sessionData) { // echo ‘write called’; try { $currentTime = time(); $payload = base64_encode($sessionData); $userId = isset($_SESSION[‘login_RegNo’])? $_SESSION[‘login_RegNo’] : null; $ip = $this->getIP(); $userAgent = $this->getUserAgent(); $stmt = $this->connection->prepare("REPLACE INTO sessions (`id`, `last_activity`, ..

Read more

I’m using laravel 8 and I changed my session driver to database now I want to get my users session and make some changes like deleting some products from users cart that I stored before in session I can get users session with this code $userSession = unserialize(base64_decode(auth()->user()->session->payload)); but now I want to update the ..

Read more

session does not exist here is the route and controller code Route Route::get(‘admin’,[AdminController::class,’login’]); Route::post(‘admin/login’,[AdminController::class,’auth’])->name(‘admin.admin_login’); **controller** public function auth(Request $request) { $email=$request->post(’email’); $password=$request->post(‘password’); $result=Customer::where([’email’=>$email,’password’=>$password])->where([‘type’=>’admin’,’status’=>’1′])->get()->first(); if($result){ $request->session()->put(‘admin_login’,true); $request->session()->put(‘admin_name’,$result->name); $request->session()->put(‘admin_id’,$result->id); $request->session()->put(‘admin_email’,$email); return redirect(‘admin_dashboard’); }else{ alert()->error(‘Invalid Login Details’)->persistent(‘close’)->autoclose(5000); return redirect(‘admin’); } } **layout** <form action="{{route(‘admin.admin_login’)}}" method="post"> @csrf <div class="input-group mb-3"> <input type="email" name="email" class="form-control" placeholder="Email"> <div class="input-group-append"> <div class="input-group-text"> ..

Read more

Simple Laravel code & markup chain: // Initial route public function play(Request $request) { … $test = session(‘test’); session()->keep([‘test’]); $sid = session()->getId(); Log::debug(‘session ID before card = ‘ . session()->getId()); Log::debug(‘session before card = ‘ . print_r(session()->all(), true)); return view(‘front.intro’, compact(‘test’, ‘sid’)); } // front.intro view excerpt @section(‘content’) <form role="form" method="get" action="{{ route(‘player.card’) }}"> @csrf ..

Read more

I’m having some issues with adding arrays to a session in laravel, and it adds the latest but never adds a second value to the array, it looks like it clears and then adds it, I have no other code related to this specific session anywhere else $request->session()->push(‘Modules.product_id’, $product->id); Am I misunderstanding the push aspect? ..

Read more

I have an initial form where I fill in some input data and proceed to checkout payment where user enter their credit card credentials.At this view, I do not really want to display the session data. After submitting the payment, it should hit the paymentRequest method. Inside, the method, I want to verify if the ..

Read more

I have a question about session()->flash(). When the data is returned to the view but is not delete on the next request. In the Controller: foreach ($req as $key => $value) { if ($value != ‘on’) { $request->session()->flash($key, $value); } } return redirect()->back()->with(‘error’, ‘No se agregaron opciones’); In the view: @if (session($dato->id)) @foreach (session($dato->id) as ..

Read more

I need to be able to use an array in session please. I want to store diffrents candidate_id to find the candidates later. CandidateController : public function search(Request $request) { $data=$request->validate([ ‘keyword’ => ‘required’, ‘word’ => ‘required’,]); $keyword= $data[‘keyword’]; $key= $data[‘key’]; $candidate = candidate::where($key, $keyword)->get(); return view(‘candidate.list’, compact(‘candidate’)); } what are the changes that I ..

Read more

I am trying to add more than one product having same ID but different sizes. How can I do that. But It just override my previous product item that is added with the different size if(!$cart) { $cart = [ $request->product_id => [ "id" => $request->product_id, "name" => $request->product_name, "quantity" => $request->quantity, "price" => $request->product_price, ..

Read more

I’m looking to use redis sentinel to store laravel sessions. I have set up redis this way: When I use Laravel’s Cache::put and do a dd(Redis::connection(‘cache-connection’)->keys(‘*’)). I do have the new values that I wanted to cache. However when I try to insert a new session value like this: Session::put(‘dddd’, ‘test’); I get nothing new ..

Read more

I just started using Laravel and i have an issue; I am sending a post request to subdomain and i can not put session data. When i try to send a get request same url, i can put session data. I tried set these in session.php ‘cookie’ => ‘laravelsession’, and ‘domain’ => ‘.mydomain.com’, and ‘secure’ ..

Read more