user3603478
user3603478

Reputation: 23

Symfony2 - Can you submit post data with redirect?

I want to submit some data in post method when redirecting to another page. The solution coming in my mind is-

  1. Create a form with post values and use javascript redirect. [depend on js enable]
  2. sending data using curl and the do something like header redirect [depend on curl enable]

Is there any other method to do it or something native to Symfony2? Like for example when using redirect method in Symfony can I send some data in post method along it?

Upvotes: 1

Views: 1864

Answers (1)

Hmmm
Hmmm

Reputation: 1764

Why dont you use sessions to store values before redirecting, this will be much easier

// Set a session value
$session = $this->getRequest()->getSession();
$session->set('session name', 'session value');

// redirect
$this->redirect('redirect to somewhere');

get the session value after redirecting

 $value = $session->get('session name');

Upvotes: 2

Related Questions