lundi 12 septembre 2016

The way of defining class methods without the need of keeping the order of calling them

Hi I have a class which includes two methods. One of which is to initialize session , another one is for redirect the web page I ve written the class such that it can be called repeatedly.

  $obj->setSession(key,value)->redirect(url);

In this mode , the session is firstly initialized and then it redirects to the next page. But if it's written like this

  $obj->redirect(url)->setSession(key,value);

It just redirects to the defined location qnd the session is not initialized anymore .. It s cuz when the resirect method is called, the page changes promptly and it causes the second method not to be called .. Is there any way to be able to call methods repeatedly without the need of considering their order ?

Aucun commentaire:

Enregistrer un commentaire