[ic] Why doesn't products stay on basket after logout?

Chris Rapier rapier@psc.edu
Tue, 17 Apr 2001 13:49:07 -0400


"Thomas N. Stefanidis" wrote:
> 
> Hello,
> When a user adds some products in his basket and then leave,after he has
> logged in again,the products in his basket have disapper.
> Any ideas how to avoid that?

When you log out you are removing all of the information regarding that
session for that user. The only way to maintain the basket/cart after
logging out is to save it first. This is actually pretty easy though :)

I do not know if there is a 'cart storage area' in any of the demos for
interchange but the following code does work for me under minivend
4.04a. Its probable that the will conform closely enough for you to just
drop this code (taken from simple ord/basket.html) into place:

[if session logged_in]
[userdb function=get_cart_names hide=1]
<P>
<FONT SIZE="+2">Cart Storage Area</FONT>
<FORM NAME="cart_storage" ACTION="[process-target secure=1]" METHOD=POST
onsubmit="validate();">
<INPUT TYPE=hidden NAME=mv_session_id VALUE="[data session id]">
<INPUT TYPE=hidden NAME=mv_todo VALUE=return>
<INPUT TYPE=hidden NAME=mv_nextpage VALUE="basket">
<TABLE WIDTH="350" border=0 cellpadding=0>
        <COL WIDTH="40%">
        <COL WIDTH="40%">
        <COL WIDTH="20%">
        <THEAD>
                <TR VALIGN=TOP>
                        <TH WIDTH="40%">
                                <P>New Cart Name</P>
                        </TH>
                        <TH WIDTH="40%">
                                <P>Existing Cart Name</P>
                        </TH>
                        <TH WIDTH="20%">
                                <P>Confirm</P>
                        </TH>
                </TR>
        </THEAD>
        <TBODY>
<TR VALIGN=TOP><TD VALIGN=top ALIGN=center WIDTH="40%">
        <INPUT TYPE=text NAME=c_nickname0 SIZE=20 VALUE="[tag
time]%b-%d-%Y:%H:%M[/tag]">
        </TD><TD WIDTH="40%">
                <SELECT NAME=c_nickname MULTIPLE>
                [loop arg="[value carts]" option=c_nickname]
                [sort code]
                <OPTION VALUE="[loop-code]"> [loop-code]
                [/loop]
                </SELECT>
        </TD><TD WIDTH="20%">
        <INPUT TYPE=checkbox NAME=c_delete VALUE=1> Yes, delete
        [scratch c_delete_message]
        [set c_delete_message][/set]
        </TD></TR>
<TR VALIGN=TOP BORDER=0><TD COLSPAN=3 ALIGN=CENTER>
        <INPUT TYPE=submit NAME=mv_check VALUE="Save to new cart">
        <INPUT TYPE=submit NAME=mv_check VALUE="Recall cart(s)">
        <INPUT TYPE=submit NAME=mv_check VALUE="Save to existing cart">
        <INPUT TYPE=submit NAME=mv_check VALUE="DELETE cart">
    </center>
  </td>
</tr>
[/if]

[set Save to new cart]
[value name=c_nickname set="[value c_nickname0]"]
[userdb function=set_cart nickname="[value c_nickname]"]
[/set]

[set Save to existing cart]
[userdb function=set_cart nickname="[value c_nickname]"]
[/set]

[set Recall cart(s)]
[userdb function=get_cart nickname="[value c_nickname]"]

[set Recall cart(s)]
[userdb function=get_cart nickname="[value c_nickname]"]
[/set]

[set DELETE cart]
[if value c_delete]
[value name=c_delete set=""]
[userdb function=delete_cart nickname="[value c_nickname]"]
[else]
[set c_delete_message]Must click the checkbox.[/set]
[/else]
[/if]
[/set]