rjgamer Posted March 3, 2021 Share Posted March 3, 2021 Hi guys, the field "redirect_last" of type DateTime got not updated. The update on the field "redirect_counter" works and got saved. Does anybody know what I did wrong in my code? if ($input->urlSegment(1) === 'redirect') { $page->of(false); $page->redirect_last = time(); $page->redirect_counter += 1; if ($page->save('redirect_counter')) { $session->redirect($page->website_url, 302); } } Thanks. Link to comment Share on other sites More sharing options...
rick Posted March 3, 2021 Share Posted March 3, 2021 You aren't saving the redirect_last field. Also, I don't think it is necessary to test the counter prior to redirecting. Try this and see if it fits your needs. if ($input->urlSegment(1) === 'redirect') { $page->of(false); $page->redirect_last = time(); $page->redirect_counter += 1; $page->save(); $session->redirect($page->website_url, 302); } 1 1 Link to comment Share on other sites More sharing options...
rjgamer Posted March 3, 2021 Author Share Posted March 3, 2021 Omfg, I was blind. 🙂 From... $page->save('redirect_counter') ...to... $page->save() ...did it. Sometimes I cannot see the tree because of the forest... or somehow. 🙂 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now