Jump to content

Affiliate Cookie Query across sub-domains


Terra

Recommended Posts

I'm using http://www.mydomain.com and whmcs.mydomain.com. In the old * I could change the cookie code to cover all sub-domains like so:

 

setcookie("WHMCSAffiliateID", $aff, time()+60*60*24*60,'/','.mydomain.com');

 

Can anyone advise what the code would look like with the new code?

 

default is

 

WHMCS_Cookie::set('AffiliateID',$aff,'3m');

 

Does anyone know how I can add the domain information into this so it covers all my sub-domains?

 

Many thanks, Edith

Link to comment
Share on other sites

Hi Edith!

 

It seems that the functionality you want (the ability to set the domain filter of a cookie) is currently not available. So, first, I would ask that you please go ahead and submit a Feature Request for this functionality, giving your above scenario as a usage case. Once you do so, post the link to your request on this thread.

 

---------

 

What you want to do *is* feasible to do on your own, however, I would suggest it is probably inadvisable, due to unknown potential ramifications of an arbitrary, untested change to an internal cookie. However, if you're willing to live with any and all potential negative side-affects, here is how I would do this, if I were in your shoes. But please, Edith, thoroughly test the app after your changes.

 

/* THIS CODE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

// 1. Set the cookie as normal: 
WHMCS_Cookie::set('AffiliateID', $aff, '3m');
// This will ensure that any and all behind-the-scenes things that should be done get done.

// 2. Kill the cookie.
// 2a. Remove PHP's knowledge of the cookie.
unset($_COOKIE["WHMCSAffiliateID"]);

// 2b. Set the browser's cookie to timeout and die immediately.
setcookie("WHMCSAffiliateID", "", time() - 3600);

// 3. Create a new cookie with your desired domain filter.
// 3a. Calculate the expiration time, in seconds. Default for this particular cookie is 3 months.
$expires =  time() + (3 * 30 * 24 * 3600);

// 3b. Create it.
setcookie("WHMCSAffiliateID", $aff, $expires, "/", ".yourdomain.com", false, true);

Link to comment
Share on other sites

Hi Edith!

 

It seems that the functionality you want (the ability to set the domain filter of a cookie) is currently not available. So, first, I would ask that you please go ahead and submit a Feature Request for this functionality, giving your above scenario as a usage case. Once you do so, post the link to your request on this thread.

 

 

Hi Ted,

 

Thank you for taking the time for your detailed reply!

 

As suggested, I have submitted this as feature request: https://requests.whmcs.com/responses/ability-to-set-domain-filter-on-whmcs-cookie

 

Many thanks, Edith

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated