Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Symfony 3 + php7 nie działają cookies
Forum PHP.pl > Forum > PHP
dekros
Witam mam taki problem ponieważ nie chcą mi wgl działać cookies przykładowo:
$cookie = new Cookie('foo', 'bar', strtotime('now + 10 minutes'));
dump($cookie);
i dump:
Cookie {#3487 ▼
#name: "foo"
#value: "bar"
#domain: null
#expire: 1518912200
#path: "/"
#secure: false
#httpOnly: true
-raw: false
-sameSite: null
}
a kiedy sprawdzam w zbadaj element-> application->cookies nic tam nie mam, za to jak ustawie cookies standardowo w czystym php(bez frameworka) wszystko działa,
ustawiałem cookie_domain na localhost etc ale i tak nic nie pomagało, jakieś rady?
pm7
Możesz pokazać cały kod? Dodałeś ciasteczko do nagłówków?
$response->headers->setCookie(new Cookie('foo', 'bar'));
dekros
Nie zabardzo wiem jak ci odpowiedzieć ponieważ w symfony używałem:
https://symfony.com/doc/current/security/fo...ogin_setup.html dokładnie tego tutoriala
a mój testowy cookies ustawiłem:
w tej funckji:
public function login(Request $request, AuthenticationUtils $authUtils)
{
// get the login error if there is one
$error = $authUtils->getLastAuthenticationError();

// last username entered by the user
$lastUsername = $authUtils->getLastUsername();

return $this->render('security/login.html.twig', array(
'last_username' => $lastUsername,
'error' => $error,
));
}
na samej górze
pm7
Jeśli problem dotyczy zapamiętania zalogowanego użytkownika, sprawdź ten link:

https://symfony.com/doc/3.3/security/remember_me.html

  1. // app/config/security.php
  2. $container->loadFromExtension('security', array(
  3. // ...
  4.  
  5. 'firewalls' => array(
  6. 'main' => array(
  7. // ...
  8. 'remember_me' => array(
  9. 'secret' => '%secret%',
  10. 'lifetime' => 604800, // 1 week in seconds
  11. 'path' => '/',
  12. // by default, the feature is enabled by checking a
  13. // checkbox in the login form (see below), uncomment
  14. // the following line to always enable it.
  15. //'always_remember_me' => true,
  16. ),
  17. ),
  18. ),
  19. ));
dekros
Problem dotyczy tego dokładnie że podając dobre login/hasło tak jakby formularz nie wysłał danych tylko ktoś kliknał F5, sprawdze ten link do podałeś i edytuje jeśli coś zadziała

EDit:
tak wygląda mój security.yaml
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: ~
remember_me:
secret: '%env(APP_SECRET)%'
lifetime: 604800
path: '/'
token_provider: App\Repository\UserRemembermeTokenRepository
form_login:
login_path: auth_login
check_path: auth_login
csrf_token_generator: security.csrf.token_manager
default_target_path: panel_dashboard
logout:
path: auth_logout
invalidate_session: true
target: auth_login
handlers: [App\Service\UserActionLogger]
guard:
authenticators:
- App\Security\Authenticator\OauthConnectAuthenticator
i nadal po wpisaniu danych nic się nie dzieje nawet złe dane nie wywołują błedu żadnego
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.