Forums / Developer / How-to avoid double post into custom modules

How-to avoid double post into custom modules

Author Message

Sébastien Antoniotti

Monday 14 December 2009 2:02:10 am

Hi,

I have a custom module who creates eZ objects based on post data.

After the publication made by the module, I would like to redirect the user to some view and disable the possibility to re-post the form (with F5 by example).

The problem is that $module->redirect... does the redirection but post data are still here.

I think a header redirection can do the job but I haven't found how to redirect properly to a custom module/view...

any ideas ?

eZ Publish Freelance
web : http://www.webaxis.fr

Łukasz Serwatka

Monday 14 December 2009 2:19:01 am

Hi,

There are few possibilities. Easiest will be set session variable after object was created and check it before. Or set a remote_id for created object which will be a hash included in the POST array and check if object exists with such remote_id if so then you skip creation process.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Sébastien Antoniotti

Monday 14 December 2009 2:47:23 am

Thanks Lukasz for the advice !

Meanwhile I found the following solution which is to redirect in 301 on the confirmation page.

In this way, post data no longer exist.

// redirect
eZHTTPTool::redirect( eZSys::indexDir().'/member/mywallet', array(), 301 );
eZExecution::cleanExit();

Cheers,

Seb

eZ Publish Freelance
web : http://www.webaxis.fr