0

I created a html page and create form on it . I want send data of my form to a form that I create . I use session but when I use session and refresh page , other session was delete or when i use session_unset(); the sessions in 4 or 5 time refresh age was show .

What is the right way for save session for anonymous users?

I use $_SESSION['test'] but I think that it's not good way .

0

1 Answer 1

0

If you get form content that is outdated since 4 or 5 refreshes this could be a caching issue. You can try to add a cache context to the form:

$form['#cache']['contexts'][] = 'session';

Or if this doesn't help disable the render cache for the form:

$form['#cache']['max-age'] = 0;
2
  • Thanks . But I have many sessions . So how can I use that ? $_SESSION['a'][$loop] , $_SESSION['b'][$loop] , $_SESSION['c'][$loop] . And $loop = 0 and with for I crease that ( $loop++).
    – user60258
    Feb 22, 2017 at 14:57
  • 1
    This is one session, it doesn't matter how much data you store.
    – 4uk4
    Feb 22, 2017 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.