browser issue - cookie detection
Moderator: General Moderators
browser issue - cookie detection
recently swapped over to firefox and an error has arose in a website i am currently testing.
to retrieve returning customers orders i use a cookie that holds a reference no. to their order (this cookie is destroyed on completion of your order). in IE this works fine, the user is returned to the shop front where a new cookie is created with a new reference no. but in firefox the cookie does not get destroyed and the new cookie does not get created which leads to some borked functionality.
i realise this is beacuse the way the browsers store cookie information. it seems firefox holds the data in a single file cookies.txt while IE creates a seperate files for each cookie.
if im mistaken please correct me but this is my initial analysis on the problem.
is there a way to safely detect the users browser to compensate for this oversight?
thanks.
to retrieve returning customers orders i use a cookie that holds a reference no. to their order (this cookie is destroyed on completion of your order). in IE this works fine, the user is returned to the shop front where a new cookie is created with a new reference no. but in firefox the cookie does not get destroyed and the new cookie does not get created which leads to some borked functionality.
i realise this is beacuse the way the browsers store cookie information. it seems firefox holds the data in a single file cookies.txt while IE creates a seperate files for each cookie.
if im mistaken please correct me but this is my initial analysis on the problem.
is there a way to safely detect the users browser to compensate for this oversight?
thanks.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Creation:
Descrution: (executed after payment has been completed and order has been processed)
Code: Select all
if(isset($_COOKIE['orderRef'])){
//retrieve cookie data for use
}
else{
$reference = md5(uniqid(rand(), true));
setcookie("orderRef", $reference, time() + 86400);
}Code: Select all
setcookie("orderRef", "", time() - 86400);
setcookie(session_name(), "", time() - 86400);
session_destroy();- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
left those parameters out on creation/descruction, tbh quite new with cookies...
ok, after visiting shop.php
Array ( [PHPSESSID] => 17c1cc76f4c6467305cd0ca8e963acca [sessionRef] => dbfe4c6c89b0181f098f58622f867872 )
after completing order (user redirected to script/process_order.php which tidys up and redirects to thank you page display invoice)
Array ( [PHPSESSID] => 17c1cc76f4c6467305cd0ca8e963acca [sessionRef] => dbfe4c6c89b0181f098f58622f867872 )
so both the session and cookie are not getting destroyed with the code im using...;/
ok, after visiting shop.php
Array ( [PHPSESSID] => 17c1cc76f4c6467305cd0ca8e963acca [sessionRef] => dbfe4c6c89b0181f098f58622f867872 )
after completing order (user redirected to script/process_order.php which tidys up and redirects to thank you page display invoice)
Array ( [PHPSESSID] => 17c1cc76f4c6467305cd0ca8e963acca [sessionRef] => dbfe4c6c89b0181f098f58622f867872 )
so both the session and cookie are not getting destroyed with the code im using...;/
before shop.php
0 cookies
after shop.php
Name PHPSESSID
Value ba6f7a5dff509011d21ada1de8b86a67
Host http://www.individ-jewels.co.uk
Path /
Secure No
Expires At End Of Session
Name sessionRef
Value 14235b1346e7f99695a6b48416fb3d56
Host http://www.individ-jewels.co.uk
Path /
Secure No
Expires 27 January 2007 21:24:17
after order completion:
Name PHPSESSID
Value ba6f7a5dff509011d21ada1de8b86a67
Host http://www.individ-jewels.co.uk
Path /
Secure No
Expires At End Of Session
Name sessionRef
Value 14235b1346e7f99695a6b48416fb3d56
Host http://www.individ-jewels.co.uk
Path /
Secure No
Expires 27 January 2007 21:25:29
clearly updating it rather then destroying it...strange
0 cookies
after shop.php
Name PHPSESSID
Value ba6f7a5dff509011d21ada1de8b86a67
Host http://www.individ-jewels.co.uk
Path /
Secure No
Expires At End Of Session
Name sessionRef
Value 14235b1346e7f99695a6b48416fb3d56
Host http://www.individ-jewels.co.uk
Path /
Secure No
Expires 27 January 2007 21:24:17
after order completion:
Name PHPSESSID
Value ba6f7a5dff509011d21ada1de8b86a67
Host http://www.individ-jewels.co.uk
Path /
Secure No
Expires At End Of Session
Name sessionRef
Value 14235b1346e7f99695a6b48416fb3d56
Host http://www.individ-jewels.co.uk
Path /
Secure No
Expires 27 January 2007 21:25:29
clearly updating it rather then destroying it...strange
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA