मैं "मुझे याद रखें" सिस्टम प्राप्त करने के लिए एक लॉगिन नियंत्रक के भीतर एक कुकी सेट करने का प्रयास कर रहा हूं। भले ही मैंने वेब पर मिले सटीक कोड का उपयोग किया है, मेरे लिए चीजें गलत हो रही हैं। मुझे आशा है कि आप मुझे यह जानने में मदद कर सकते हैं कि मैं क्या खो रहा हूं।Symfony2: कुकी को सेट करना
के कोड के माध्यम से चलते हैं:
public function loginAction(Request $request) {
// Receiving the login form
// Get Doctrine, Get EntityManager, Get Repository
if(/* form information matche database information */) {
// Creating a session => it's OK
// Creating the cookie
$response = new Response();
$response->headers->setCookie(new Cookie("user", $user));
$response->send();
$url = $this->generateUrl('home');
return $this->redirect($url);
} else
return $this->render('***Bundle:Default:Login.html.php');
}
मैं इन में शामिल हैं:
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Cookie;
ध्यान दें कि प्रवेश में ठीक काम करता है, सत्र बना दिया गया है, लेकिन कुकी नहीं है।
यह काम करता है। धन्यवाद m2mdas। –