Category : session

I have uploaded my project to CPanel, and everything was working smoothly. However, I noticed that after login the exceptions where I used if (Auth::check() && Auth::user()->id) {…} else{…} if (Auth::check() && Auth::user()->role_id === 1) {…} else{…} if (Auth::check() && Auth::user()->role_id === 1) {…} else{…} does not appear but everything works fine without any errors. ..

Read more

I have 4 framework files: /config/framework.yaml: framework: csrf_protection: true session: # enables the support of sessions in the app enabled: true # ID of the service used for session storage. # NULL means that Symfony uses PHP default session mechanism handler_id: SymfonyComponentHttpFoundationSessionStorageHandlerRedisSessionHandler # improves the security of the cookies used for sessions cookie_secure: true cookie_lifetime: ..

Read more

I’m writing a shopping cart page for shoes shop website using sessions in Symfony for PHP. It enables to add an item of selected size to cart and count a quantity. Here’s a function of adding a product: public function add($shoesid, $sizeid, SessionInterface $session) { $cart = $session->get(‘cart’, []); if(!empty($cart[$shoesid][$sizeid])) { $cart[$shoesid][$sizeid]++; } else { ..

Read more

I’m writing my own shoes shop website using Symfony for PHP. With a help of sessions I need to add a product to shopping cart with selected size of it. Here’s a code: /** * @Route("/cart/add/{shoesid}/{sizeid}", name="cartAdd") */ public function add($shoesid, $sizeid, SessionInterface $session) { $cart = $session->get(‘cart’, []); if(!empty($cart[$shoesid[$sizeid]])) { //error here $cart[$shoesid[$sizeid]]++; } ..

Read more