Setting cookie domain

I need to set a cookie for the selected index of a webform, so it can carry across multiple posts and keep the state (in other words if they select option1, and submit, then option1 is still selected on the form again, etc.)
this is the script i'm using to set the cookie:
function get_selected_state(){
               var selected_state = $('select[id="CAT_Custom_414023"] option:selected').val();
               setCookie('selected_state', selected_state, '/', '.domain.businesscatalyst.com');     
          function setCookie(c_name,value,path,domain,exdays){
               var exdate=new Date();
               exdate.setDate(exdate.getDate() + exdays);
               var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()+";path="+path+";domain");
               document.cookie=c_name + "=" + c_value;
          function getCookie(c_name){
               var i,x,y,ARRcookies=document.cookie.split(";");
               for (i=0;i<ARRcookies.length;i++){
                    x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
                    y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
                    x=x.replace(/^\s+|\s+$/g,"");
                    if (x==c_name){
                         return unescape(y);
          // if the cookie for state selection exists, set the form to it
          if(c = getCookie('selected_state')){
               $('option[value="'+c+'"]').attr('selected', 'selected');
          // set the cookie to the current selection
          get_selected_state();
          // and update it on reselection
          $('select[id="CAT_Custom_414023"]').on('change', function(){
               get_selected_state();
I've been checking it on the client site with greasemonkey and it works fine, but it doesn't work on the server. I figured the problem was the domain but I don't seem to be able to set the domain to match properly. What am I doing wrong here?

You got a dot at the start of your cookie domain. Should not be there. Should be just domain.businesscatalyst.com and then the live domain when live. The cookie of course wont work through worldsecuresystems as a side note.

Similar Messages

  • Not able to set cookie domain ???

    Hi All,
    I am not able to set cookie domain in my webapp(WebApp.mydomain.com).
    My sample code is given below, my webapp name is WebApp.mydomain.com, this has got two jsp pages, one for creating cookie and other one is for reading the cookie.
    CreateCookie.jsp
        Cookie cookie = new Cookie("id","123");
              cookie.setDomain(".mydomain.com");
              cookie.setPath("/");
              response.addCookie(cookie);ReadCookie.jsp
    Cookie[]cks = request.getCookies();
              for(int i=0;i<cks.length;i++){
           out.print("cookie found.............................   "+cks.getValue());
    Issues:
    1. I am not able to read the cookie, if i set the domain as cookie.setDomain(".mydomain.com"); at cookie. I verified it by commenting the domain setting line.
    2. The reason for setting the domain is, I have another web application "WebApp1.mydomain.com" which is supposed to read this cookie which is created in "WebApp.mydomain.com" application.
    3. Is it possible to access the cookie across the applications as the cookie domain and path are been set. (i.e) From WebApp.mydomain.com to WebApp1.mydomain.com?Please share your inputs :(
    Thanks,
    Sundar

    Hi All,
    Any comment/solutions on this???
    Regards,
    Sundar

  • Frmrwinteg: how to set cookie domain dynamically

    We are using the frmrwinteg bean for calling reports without sso with passing the userid info in an encrypted cookie. We have the following problem:
    We have to pass 'servername.domain' as the cookie domain value, e.g. 'formsserver.company.com'. Although the manual states that just passing the domain (i.e. '.company.com') is enough, we did not manage to get this working.
    Now we have a server that can be approached in two ways:
    - Directly, using the server's hostname
    - Through a reverse proxy (ibm webseal), using the proxy name.
    We have configured both servername:port combinations as virtual hosts on the http server, so both connections work, but the cookiedomain must now be set depening on which way it is called.
    The question is: can we determine within Forms (maybe using webutil?) what the original url was from where the form is started? In that case we can dynamically determine the correct value for the cookie domain.
    Or is there a way to get the cookie working with just '.company.com' as the cookie domain?

    I found some documentation why our cookie domain does not work. '.company.com' would work, but '.company.nl' (or any other country code) does NOT work. See explanation below:
    However, you CAN use it accross different hosts on the same domain, provided the domain either:
    1. ends with edu, net, gov, mil, com or org and contains at least 1 dot in it (eg you could specify xxxx.com, and use it on hosta.xxxx.com and hostb.xxxx.com) OR
    2.) ends with a country code and contains 2 dots in it (eg you could specify xxxx.com.au and use it on hosta.xxxx.com.au and hostb.xxxx.com.au).
    So it seems the servernames have to be extended with an extra level, e.g. 'hostname.servers.company.nl'.
    I do not think my customer will ever want to do that.

  • How to set the domain of a cookie in localhost environment

    in some scenario i have to set the domain of cookie on my local environment,
    how can be done?????????????
    i.e http://localhost:7001/myapp/testservlet
    how to set the cookie domain for "myapp"

    Hi
    After Some googling I could find out this for you. I think it is a bug with IE.
    http://www.webmasterworld.com/forum21/11530.htm
    The idea is to use a virutal host.
    HTH
    VJ

  • Setting cookies across domains

    Hi there all,
    I'm posting this in desperation to be honest, don't think
    there is a cut'n'dried
    answer to this one.
    I've got a horrible situation, (don't ask why, it's far too
    complex and to
    be quite honest.. boring :) ).
    I'm trying to "mesh" together a classic .asp with an asp.NET
    site on 2
    separate domains.
    Basically I've got a page from the asp.NET site (eg.
    www.something.co.uk)
    displayed within an iframe on the .asp (eg
    www.another.co.uk). So far so
    good.
    I need to set a cookie on www.another.co.uk and be able to
    read it, or
    replicate it on www.something.co.uk. Because they are not
    sub-domains I can't
    set the cookie direct because of security restrictions.
    So, I thought I could pass a URL variable across to
    www.something.co.uk via
    the iframe URL, and then using javascript to read said URL
    variable and set
    a cookie on the www.something.co.uk domain. No go. Suspect
    there is yet
    again security restrictions to setting cookies across domains
    using iframe.
    So I'm kind of stuck. Can anybody suggest anything please,
    bearing in mind I
    have very limited control over the asp.NET
    (www.something.co.uk) site, so
    any solution I come up with needs to be using javascript.
    Major sized thanks in advance.
    @ndyB

    You could also pass the id as a hidden field in a form.
    Have the link call a JavaScript function. The JavaScript funcition could access the cookie and pull out the id. The function would then set a hidden field in a form to the id value and then Post the form to the secure server.
    The form would only have hidden fields so it could be tagged on the end of the HTML page and the user would never know it was there.

  • How to deal with the "Set-Cookie" field in HTTP header??

    I follow the RFC-2616 specification to write a socket program to fetch web pages.
    I have to deal with all the fields included in the HTTP header.
    But the RFC-2616 doesn't talk anything about the "Set-Cookie" field.
    Does anyone know how to handle this field or provide me any useful documentation.
    Any help is appreciated.

    A cookie is set with the "Set-Cookie: "-field in the http header, like this:
    Set-Cookie: mycookie=someValue
    This cookie should only be returned to the same host as it came from, like this in the http header of a request:
    Cookie: mycookie=someValue
    If the parameter looks like this:
    Set-Cookie: mycookie=someValue; path=/cgi-bin
    , the cookie should only be returned to the host if the request path starts with /cgi-bin
    If the parameter looks liek this:
    Set-Cookie: mycookie=someValue; domain=.mydomain.com
    , the cooke should be returned to all hosts in the .mydomain.com-domain
    There is also a "expires="-field, which works as expected and a "secure"-field, which I'm not sure how to handle. Maybe the cookie should only be sent to an SSL-enabled host?
    Hope this helps you. Bye,
    Dag W.

  • Set cookie in webservice request

    Hi,
    Is there a way to set a cookie in a webservice request or include the HttpCookie in the service call ? Basically I am using Axis on client side to call a .NET webservice on a remote server and need to pass user data to the service in a cookie.
    Thanks
    NK

    Hi Santhiyaraman,
    Webview control is in windows phone 8.1 runtime app, in windows phone 8 is webbrowser control.
    Webbrowser control does not provide some properties or methods to add custom cookie, but we can do this using the javascript. Code snippet looks like the following.
    private void setCookie(string name, string value, string path = "", string domain = "", bool isSecure=false, string expires = "")
    var sb = new StringBuilder();
    sb.AppendFormat("document.cookie = '{0}=\" + escape(\"{1}\")", name, value);
    if (!String.IsNullOrEmpty(expires))
    sb.AppendFormat(";expires=\"{0}\"", expires); // should be a GMTString
    if (!String.IsNullOrEmpty(path))
    sb.AppendFormat(";path=\"{0}\"", path);
    if (!String.IsNullOrEmpty(domain))
    sb.AppendFormat(";domain=\"{0}\"", domain);
    if (isSecure)
    sb.Append(";secure'");
    var cookieJs = sb.ToString();
    Debug.WriteLine(cookieJs);
    webBrowser.InvokeScript(cookieJs);
    You can find more information about it from
    http://stackoverflow.com/questions/13287409/windows-phone-webbrowser-set-cookies.
    Please try and let me know the result.
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Setting cookies for safari using java

    Dear all
    I am new to cookie programming. Is there some way so that I can set cookies in Safari on Mac.
    I need to set the user's login information in cookie for a particular site then i need to launch that particular website.
    The code samples will better help. Pls help me as i am in urgent need.
    Regards
    Shobhit Jain

    Can you explain what this will do? Is this a type of
    wildcard for all domains?The answer to my question is that you can't do it, and for good reason. There is a security restriction against creating/accessing cookies from unrelated domains (and ".com" won't cut it). So I just did a complete proxy solution and translated all requests and maintained the cookies for the browser.
    I am not sure what setDomain("/") would do - I am pretty sure that is just invalid (but it is a valid path, however).

  • Set-cookie cache

    Hi All,
    If we develop the set-cookie using NSAPI on Proxy Server 4.0.2, the proxy server cache the following information.
    Request Headers
    content-length     =     165
    content-type     =     text/html
    status     =     200 OK
    Set-cookie     =     CTSESSION=AAewewedwewewew; domain=.cc.company.net; path=/
    server     =     Sun-ONE-Web-Server/6.1
    date     =     Tue, 24 Jan 2006 11:45:57 GMT
    last-modified     =     Wed, 18 Jan 2006 04:27:28 GMT
    etag     =     "a5-43cdc3b0"
    accept-ranges     =     bytes
    via     =     1.1 proxy-proxy402
    proxy-agent     =     Sun-Java-System-Web-Proxy-Server/4.0.2
    How to avoid this "Set-cookie" on cache of Proxy Server?
    regards;
    Tash

    Cannot reproduce this issue. Tried the following with 4.0.2 proxy server:
    1. Origin server sends the following response with "Set-cookie" header,
    HTTP/1.1 200 OK
    Content-length: 34
    Content-type: text/html
    Server: Sun-ONE-Web-Server/6.1
    Date: Fri, 27 Jan 2006 06:34:49 GMT
    Set-cookie: "CTSESSION=AAewewedwewewew; domain=.cc.company.net; path=/"
    Last-modified: Fri, 27 Jan 2006 06:33:33 GMT
    Etag: "22-43d9bebd"
    Accept-ranges: bytes
    Via: 1.1 S1PS
    Via: 1.1 proxy-server1
    Proxy-agent: Sun-Java-System-Web-Proxy-Server/4.0.3
    iPlanet File.
    iPlanet web server.
    2. Proxy server caches the document but without the "set-cookie" header. Following is the contents of the cached file:
    11556FFE46101FC41D     1     1138323813     0     1138323889     34
    text/html     http://dummy.com:8080/myfile8.html0014content-length0002340012content-type0009text/html0006status0006200 OK0006server0022Sun-ONE-Web-Server/6.10004date0029Fri, 27 Jan 2006 06:34:49 GMT0013last-modified0029Fri, 27 Jan 2006 06:33:33 GMT0004etag0013"22-43d9bebd"0013accept-ranges0005bytes0003via00081.1 S1PS0003via00171.1 proxy-server10011proxy-agent0038Sun-Java-System-Web-Proxy-Server/4.0.3^M
    iPlanet File.
    iPlanet web server.

  • IE not set cookie for downloaded js file.Why?

    I'm trying to  download a js file from a different domain  like main page  is from  www.abc.com but js file is from www.def.com. www.def.com sets a cookie . All major browsers get the cookie and sends it in the other requests to www.def.com.But
    IE sends this cookie to www.abc.com. Cookie has also domain field set www.def.com. Any possible solution?

    How, specifically, is the cookie set?
    When you use document.cookie to set a cookie, ALL BROWSERS set the cookie in the domain in which the script runs (e.g. the page that includes it). NO BROWSERS set the cookie in the domain from which the script downloaded.
    When you use a SET-COOKIE response header to set a cookie, MOST browsers set the cookie in the domain from which the download occurs. Internet Explorer will IGNORE that cookie (not setting it anywhere) unless a P3P statement is supplied. See
    http://blogs.msdn.com/b/ieinternals/archive/2013/09/17/simple-introduction-to-p3p-cookie-blocking-frame.aspx

  • Whats happening to my set-cookie header?

    I'm writing a desktop client for a Django app running on an https domain.
    I'm attempting to retrieve cookies set by the django site when I call the site using URLRequest as follows:
    var urlVariables = new air.URLVariables();
    urlVariables.foo = "bar"
    var request = new air.URLRequest("https://www.example.com/api/foo/");
    request.data = urlVariables;
    request.method = air.URLRequestMethod.POST;
    var loader = new air.URLLoader();
    loader.addEventListener(air.HTTPStatusEvent.HTTP_RESPONSE_STATUS, httpStatusHandler);
    loader.addEventListener(air.Event.COMPLETE, completeHandler);
    loader.addEventListener(air.IOErrorEvent.IO_ERROR, ioErrorHandler);
    loader.load(request);
    However if I loop over the headers returned by the site like so...
    function httpStatusHandler(event){
        for(var i=0; i<event.responseHeaders.length; i++){
           air.trace(event.responseHeaders[i].name);
    ...I discover that that the Set-Cookies header is conspicuously absent.
    Is this a deliberate security restriction for calls to HTTPS sites? I'm completely baffled.
    Any help appreciated.

    Go into the System Preferences and click on Users & Groups. Try creating a new user account and then log into it to see if you have the same issues. Since your hard drive appears to be fine with plenty of space on it, and you have no major permission's issues, creating a new user for test purposes will help confirm whether you are dealing with some sort of software issue. Did you recently install some new software?
    If a new user account resolves the issue then open the Activity Monitor application located in the Applications/Utiliteis folders and click on the CPU button. In the lower left corner you should see a summary listing the % User, % System, % Idle. What are these percentages? If the CPU idle percentage is near zero then you have a process running that is consuming your SPU time. To try and find it pull down the menu to select 'All Processes', then click on the %CPU column to sort by the percent that each process is consuming your CPU.   The numbers constantly change, but do your best to see if there are one or two processes consuming the majority of the CPU time and post the names. Then do the same test in the new user account. I suspect you may have some process from a previously installed utility, virus checker, etc. that is keeping your system busy. I've included a screenshot from my system below. It doesn't have much going on, and as you can see in the lower left corner the CPU is basically idle most of the time. If I were to launch a CPU intensive app the numbers would change dramatically.

  • Set cookie in Webview in Windows Phone 8.0

    The app we created runs as a webview control after initial login process. We have to send a cookie(secure httponly ) to server as part of request after first time login for consequent logins.
    There is no solution provided to set cookie in web view. Can anybody share a sample to set cookie in webview control in Windows phone 8.0 (Silverlight app)?

    Hi Santhiyaraman,
    Webview control is in windows phone 8.1 runtime app, in windows phone 8 is webbrowser control.
    Webbrowser control does not provide some properties or methods to add custom cookie, but we can do this using the javascript. Code snippet looks like the following.
    private void setCookie(string name, string value, string path = "", string domain = "", bool isSecure=false, string expires = "")
    var sb = new StringBuilder();
    sb.AppendFormat("document.cookie = '{0}=\" + escape(\"{1}\")", name, value);
    if (!String.IsNullOrEmpty(expires))
    sb.AppendFormat(";expires=\"{0}\"", expires); // should be a GMTString
    if (!String.IsNullOrEmpty(path))
    sb.AppendFormat(";path=\"{0}\"", path);
    if (!String.IsNullOrEmpty(domain))
    sb.AppendFormat(";domain=\"{0}\"", domain);
    if (isSecure)
    sb.Append(";secure'");
    var cookieJs = sb.ToString();
    Debug.WriteLine(cookieJs);
    webBrowser.InvokeScript(cookieJs);
    You can find more information about it from
    http://stackoverflow.com/questions/13287409/windows-phone-webbrowser-set-cookies.
    Please try and let me know the result.
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to set cookie value in one page and retrieve in another page using setA

    How to set cookie value in one page and retrieve in another page using setActionListener?
    I have tried with following code srcpage.jspx->destpage.jspx
    srcpage.jspx
    <af:table value="#{bindings.DepartmentsView1.collectionModel}"
    var="emp" rows="#{bindings.EMPView1.rangeSize}"
    first="#{bindings.EMPView1.rangeStart}"
    emptyText="#{bindings.DepartmentsView1.viewable ? 'No rows yet.' : 'Access Denied.'}">
    <af:column sortProperty="EmployeeName" sortable="false"
    headerText="Cookie Testing">
    <af:commandLink text="#{emp.EmployeeName}" action="success">
    <af:setActionListener from="#{emp.EmployeeName}"
    to="#{cookie}"/>
    </af:commandLink>
    </af:column>
    </af:table>
    espage.jspx
    <af:outputText value="Test Cookie Value: #{cookie}"/>
    ,Here Test Cookie Value prints the following instead of its original String value
    {JSESSIONID=javax.servlet.http.Cookie@7da288, oracle.uix=javax.servlet.http.Cookie@399f62}
    I have passed employee name "Robert" to cookie in srcpage.jspx,but it prints "JSESSIONID....." instead of "Robert" in destpage.jspx
    Thanks in advance
    Kalee

    Hi,
    "cookie" is a reserved name. If you want to write to a session scope attribute called "cookie" then you have to call #{sessionScope.cookie}. If you want to use EL to set and read from cookies then you will have to use
    #{cookie.cookieName}
    Note that #{cookie} writes to and returns a map
    check this: http://www.informit.com/articles/article.aspx?p=30946&seqNum=7
    Frank

  • HT1677 In safari browser cookies is working fine. But when I add the browser url to the screen then the cookies concept is not working. In safari setting cookies is always open only. Can you please provide any information regarding to this?

    In safari browser cookies is working fine. But when I add the browser url to the screen then the cookies concept is not working. In safari setting cookies is always open only. Can you please provide any information regarding to this?

    Hello,
    '''Try Firefox Safe Mode''' to see if the problem goes away. [[Troubleshoot Firefox issues using Safe Mode|Firefox Safe Mode]] is a troubleshooting mode that turns off some settings and disables most add-ons (extensions and themes).
    ''(If you're using an added theme, switch to the Default theme.)''
    If Firefox is open, you can restart in Firefox Safe Mode from the Help menu by clicking on the '''Restart with Add-ons Disabled...''' menu item:<br>
    [[Image:FirefoxSafeMode|width=520]]<br><br>
    If Firefox is not running, you can start Firefox in Safe Mode as follows:
    * On Windows: Hold the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * On Mac: Hold the '''option''' key while starting Firefox.
    * On Linux: Quit Firefox, go to your Terminal and run ''firefox -safe-mode'' <br>(you may need to specify the Firefox installation path e.g. /usr/lib/firefox)
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    [[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]] article to find the cause.
    ''To exit Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    When you figure out what's causing your issues, please let us know. It might help others with the same problem.
    Thank you.

  • Setting cookies in a webservice doesn't work

    I am using a ColdFusion component to publish a web service
    and I want that web service to set a cookie. However, this does not
    appear to always work.
    Specifically, if I invoke the web service from the browser by
    entering a URL such as "service.cfc?method=name" in the address
    bar, then the cookie is set properly. If I use <cfinvoke> the
    cookie is not set. If I use the EasySoap C++ library then the
    cookie is set if I use <cfheader> to set it, but is not set
    if I use <cfcookie>.
    Please see the attached code samples. "cookies.cfc" is the
    component used to publish the web service, "cookies.cfm" is a
    simple test programme which invokes the web service either using
    <cfinvoke> or with the web browser (the second time you
    invoke the web service you should see that the cookies were set the
    last time you invoked it, but this only happens if you invoke it
    using the browser. A simple C++ programme to invoke the web service
    (using EasySoap, which in turn uses WinInet) returns
    "Cookie.EchoLast_2=99" meaning that only cookies set using
    <cfheader> are actually being set.
    Please explain what on earth it is doing and what is the
    correct/approved way of setting cookies in a web service.
    Thanks!

    quote:
    Originally posted by:
    MartinW-2006
    Any suggestions? AM I right in presuming this is a bug?
    Start by ensuring that your function actually runs when you
    invoke it. Does anything get returned to your calling template?

Maybe you are looking for

  • Carry forwarding the closing  balance as opening balance

    hi, i need  to carry forward the closing balance of the 1 month to the opening balance of the next month. how to do this in the query.?

  • Looping back to 'Match Test' after incorrect 1st try

    I've just done my first Captivate thing and really like the program. But I've had a problem with the Match Test... - Student incorrectly matches by dragging & dropping and then clicks continue... - We loop them back to the the lesson slide - Then bri

  • Documents Related to WAD

    Dear Friends, I am trying to build a dashboard on WAD. I am getting too many formatting problems. friends can you please help me to understand WAD or suggest me some document or tutorial. I will be greatful to you. regards Malik

  • Static routes for load balancing

    if I point 2 statics to 2 destinations, does it load balance, i.e first traffic goes one way, next goes the other ?

  • Consequences of purging cache and optimizing

    I am running LR 2.5 on two Macs. I keep reading contradictory info about purging the cache. Most articles mention doing this and then have a caveat of but "I wouldn't recommend it." What is the worst case scenario of purging the cache? Same with opti