function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sugandhi VermaSugandhi Verma 

Cookie is not Storing the current value

page is:

<apex:page controller="TourHomeContrllr1" standardStylesheets="false" showHeader="false">
<apex:repeat value="{!naamClicked}" var="t">
    <div class="row">
    <div class="col-md-12 maincol" data-toggle="modal" data-target="#myModal" id="id1" >
                     <div style="float:right;margin-top:5px;" class="img-responsive">
		<apex:outputField value="{!t.Tour_Place_Images__c}" style="width:200px;height:200px;" > </apex:outputField></div>
                <apex:form >    
                        <div style="float:right;"><apex:inputField value="{!t.Select__c}"></apex:inputField>
 <apex:pageBlock >
                  <apex:form >
                  <apex:pageBlockSection >
                     <apex:commandButton action="{!addToCart}" value="Book Place" styleClass="btn btn-primary" rerender="select_places"/> </apex:pageBlockSection>
                     <apex:pageBlock title="Your Places" id="select_places">
 <apex:outputText value="{!cartContents}" escape="true"/> </apex:pageBlock>

controller is:

public class TourHomeContrllr1 {
  public List<Tour_Places__c> tourInformation{ get; set;}
public List<Tour_Places__c> getNaamClicked() {
        tourInformation=[Select Name,Place__c,Tour_Place_Images__c,Select__c,Tour_Name__c,Tour_Price__c from Tour_Places__c where Tour_Name__c in :[Select Name from Tours__c where Id =:ApexPages.currentPage().getParameters().get('oid')] ];
    return tourInformation;
  public List<Tour_Places__c> bookInformation{ get; set;}
public List<Tour_Places__c> getSelectClicked() {
        bookInformation=[Select Name,Place__c,Tour_Place_Images__c,Select__c,Tour_Name__c,Tour_Price__c from Tour_Places__c where Tour_Name__c in :[Select Name from Tours__c where Id =:ApexPages.currentPage().getParameters().get('oid')] ];
    return bookInformation;
public list<Tour_Places__c> tsel=new list<Tour_Places__c>();
    Map< String,Boolean> select_places = new Map<String,Boolean>(); 
public PageReference addToCart() {
    PageReference pageRef = new PageReference('/apex/cart');
    for(Tour_Places__c p :tourInformation ) {
            select_places.put(p.Place__c, p.Select__c);
            cookieJar c = new cookieJar(p.Place__c, p.Name, String.valueOf(p.Select__c)); 
    // return pageRef;
    return null;
public String getCartContents() {
 if(0 == select_places.size()) {
        return '(cart is empty)';
    String msg = '<ul>\n';
    for(String id : select_places.keyset()) {
    msg += '<li>';
        msg +=  id + ' (' + select_places.get(id) + ')';
        msg += '</li>\n';
    msg += '</ul>';
     Cookie theCookie;
    theCookie = ApexPages.currentPage().getCookies().get('Place__c');
    if(theCookie != null)  
    msg +=theCookie.getValue();
    theCookie = ApexPages.currentPage().getCookies().get('Name');
    if(theCookie != null)  
    msg +=theCookie.getValue();

    theCookie = ApexPages.currentPage().getCookies().get('Select__c');
    if(theCookie != null)  
    msg += theCookie.getValue();
    return msg;
public class cookieJar {
        public cookieJar(String place, String Name, String tselect) {
            Cookie pplace = new Cookie('place', place,null,315569260,false);
            Cookie pName = new Cookie('Name', Name,null,315569260,false);
            Cookie qselect = new Cookie('tselect', tselect,null,315569260,false);
            //Set the page cookies using the setCookies() method
            ApexPages.currentPage().setCookies(new Cookie[]
            {pplace, pName, qselect} );
    }//end cookieJar inner class

please let me know how to store the selected items only in the cookie...and send the values to the another page.

See if this link helps,
Sugandhi VermaSugandhi Verma
Hi Santosh,

If u have any example(code) that is storing the checked checkbox value then please share the link.
Sugandhi VermaSugandhi Verma
I have done the same but it is taking all the values....please see my code above.