Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Symfony 3 + php7 nie działają cookies
dekros
post 18.02.2018, 00:57:07
Post #1





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 9.07.2015

Ostrzeżenie: (0%)
-----


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?
Go to the top of the page
+Quote Post
pm7
post 18.02.2018, 12:24:01
Post #2





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 28.09.2017

Ostrzeżenie: (0%)
-----


Możesz pokazać cały kod? Dodałeś ciasteczko do nagłówków?
$response->headers->setCookie(new Cookie('foo', 'bar'));
Go to the top of the page
+Quote Post
dekros
post 18.02.2018, 12:42:52
Post #3





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 9.07.2015

Ostrzeżenie: (0%)
-----


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
Go to the top of the page
+Quote Post
pm7
post 18.02.2018, 13:28:01
Post #4





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 28.09.2017

Ostrzeżenie: (0%)
-----


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. ));
Go to the top of the page
+Quote Post
dekros
post 18.02.2018, 13:40:53
Post #5





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 9.07.2015

Ostrzeżenie: (0%)
-----


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

Ten post edytował dekros 18.02.2018, 13:45:13
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 28.03.2024 - 22:29