Zen Cart Logo
Forums / General Questions / Cookie not working

Cookie not working

Locked

Views: 716

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
20 Jan 2010, 4:34 AM
#1
hoehnt avatar

hoehnt

New Zenner

Join Date:
Dec 2009
Posts:
13
Plugin Contributions:
0

Cookie not working

Hello,

I am using the zenid as a unique identifier for naming files that a user creates when he visits a page.

I thought this was a good idea until I noticed that if a user creates several files without logging out the files get overwritten because the zenid only changes upon login.

So I decided to make a simple counter cookie that would increment every time the page was refreshed. This coulter value would somply be appended to the zenid for a truly unique file identification.

Now my problem is that cookies dont seem to be working within zen cart.

I am creating it with the following:

<?php if (!isset($_COOKIE['Counter_Cookie'])) $_COOKIE['Counter_Cookie'] = 0; $Counter_Cookie = $_COOKIE['Counter_Cookie'] + 1; setcookie('Counter_Cookie',$Counter_Cookie); ?>

viewing cookies with javascript:alert(document.cookie); shows no cookie. The files created have the zenid with a 1 appended, but the 1 never incremements.

anyone have any ideas?

Thanks,

20 Jan 2010, 4:48 AM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,646
Plugin Contributions:
0

Re: Cookie not working

Using the zenID is a bad idea - try using time or a zen_get_random() - (I hope that's the right function :) )

20 Jan 2010, 5:40 AM
#3
hoehnt avatar

hoehnt

New Zenner

Join Date:
Dec 2009
Posts:
13
Plugin Contributions:
0

Re: Cookie not working

I was origimally using time but we decided that there was a (however remote) chance 2 users could log in at the same time.

I cannot find anything on zen_get_random(). Is that documented anywhere?