0

I tried to use sessions, but are not working, so I tested them with

$_SESSION['one']        = 'one';
print_r($_SESSION);

I refreshed the browser, it works Array ( [one] => one )

I commented the $_SESSION['one'] = 'one';, I refreshed, then the result is empty, session lost, my settings are the info file. The sessions folder has some session files but no content:

ls -l /var/lib/php/sessions/

-rwxr-xr-x 1 root root   0 Nov 17 21:59 sess_v0maohltlu0lnmq6fgpo8kn2ee
-rwxr-xr-x 1 root root  63 Nov 17 22:02 sess_vbjg2ggj2jkji51sfjnq3ivisl
-rwxr-xr-x 1 root root   0 Nov 17 22:12 sess_vkqf3hu5rt4q8ltv1m9evkp6h5
-rwxr-xr-x 1 root root  63 Nov 17 22:08 sess_vn4i02e8jfg1tadn9fvaj2ppru
-rwxr-xr-x 1 root root   0 Nov 17 22:04 sess_vvmc71tntma9bpjqp7fjei65pd

sessions info file

  • The session files *are* the data. For some reason your browser is not resuming past sessions but instead is always starting a new session. – Martin Nov 17 '20 at 21:39
  • Perhaps [answers here](https://stackoverflow.com/questions/19644624/setting-session-doesnt-work-on-localhost-using-xampp) can help you? – Martin Nov 17 '20 at 21:41
  • Where and How do you `session_start()` in this code – RiggsFolly Nov 17 '20 at 21:41
  • @RiggsFolly: The sessions are started automatically using session.auto_start = 1 – Immo Broker Nov 17 '20 at 21:43
  • Did you check that that option is actually set. Not sure exactly what your **`refresh`** entailed, it's a bit of a nebulious term, but it might have reset PHP params to their default – RiggsFolly Nov 17 '20 at 21:44
  • @Martin: Once I refreshed, the session folder created 6 session files, all with 0 bytes and 1 with 63 bytes – Immo Broker Nov 17 '20 at 21:45
  • @RiggsFolly: I refresh the browser as normal use, the data is lost, how can I check it? – Immo Broker Nov 17 '20 at 21:47
  • 1
    Just to be clear, 63 bytes is more than enough data for that sample session. Have a look at one of those files in an editor, and it will probably look something like `a:2:s:3:"one":s:3:"one"` – IMSoP Nov 17 '20 at 22:05
  • @IMSoP: yeah it has data, but rest of files are null, I am wondering why the sessions are not stored correctly – Immo Broker Nov 17 '20 at 22:19
  • Can anyone send me the php.ini file 7.4, so I will replace mine and recheck with it? – Immo Broker Nov 18 '20 at 12:20

1 Answers1

0

my name is Alex Bill and I am working on EMUCoupon.com.

I think you must try to use this line

var inventoryitems = <?php echo '["' . implode('", "', $inventoryitems) . '"]' ?>;

where $inventoryitems is an array - $inventoryitems = array ("value1", "value2", "value3", "value4")