Closed (works as designed)
Project:
Domain
Version:
7.x-3.4
Component:
User interface
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
5 Jul 2012 at 08:36 UTC
Updated:
29 Nov 2012 at 15:41 UTC
Jump to comment: Most recent
Comments
Comment #1
agentrickardMake sure you set
$cookie_domain = '.main.com'first. The rest is just JS or PHP code to set/read/react to the cookie value.If you fail to set $cookie_domain, the sites cannot read a shared cookie for security reasons.
Comment #2
patoh commentedThanks agentrickard .. i have the $cookie_domain setup in the settings.php would you happen to have some code or an example of to do that redirect to url using the $cookie_domain to point me in the right direction?? id really appreciate it.
Comment #3
agentrickardThis should come close. The trick to to avoid an infinite redirect loop. You may also need to adjust the $time setting.
This code goes in a custom.module file and may be buggy.
You could also change the $time handling to be expire-based, but that likely won't work in your use case.
Comment #4
patoh commentedThanx ken .. I'll be sure to try it out and report the output.
Comment #5
patoh commentedHi. I Modded it a little bit because it was throwing some tantrums :) but it still doesnt redirect to last domain :(
Here's what i have currently
Comment #6
agentrickardWhat _does_ it do? What, if anything is set in $_COOKIE?
Comment #7
agentrickardI think this part is wrong:
You are trying to access an array above this. If the cookie cannot be an array, then each cookie needs a unique name.
What does this set:
Comment #8
patoh commentedThis is the exception it throws without the for each bit
Warning: setrawcookie() expects parameter 2 to be string, array given in ubercookie_init() (line 20 of /var/www/hivisasa/sites/all/modules/cookie/ubercookie.module).
This what the $_COOKIE Holds:
Array
(
[ubercookie_redirect] => 1342440988
[nomobi] => yes
[UUID] => 9f2cef0c-7d3f-1b64-8dff-e6cf4acc2800
[__utma] => 78302283.228827486.1342044306.1342053442.1342070418.3
[__utmc] => 78302283
[__utmz] => 78302283.1342044306.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
[SESSae96f6b4b32c957e33681ae8c7d5a4eb] => 4XqpXDoFVusowuZztNQngEv6U1iCOpm_BSsa9apTxc4
[has_js] => 1
[Drupal_toolbar_collapsed] => 0
)
Comment #9
agentrickardThen we just have a string/array mismatch because I'm used to dealing with $_SESSION, which allows arrays.
Comment #10
patoh commentedI coded the changes and it now has this two extra lines at the end of the cookie
[ubercookie_redirect_domain] => kazijob_com
[ubercookie_redirect_time] => 1342460940
which means that the cookie is now storing the domain machine name which is uber awesome :)
Now to test it out on a test server!! cross ur fingers. I hope it takes me to my last domain.
Comment #11
agentrickardIt should work now. I just forgot that $COOKIE['this_cookie'] must be a string.
Comment #12
patoh commentedHuh! What do yu mean? the machine name wont work?? or i replace the machine name with the domain?
Comment #13
agentrickardNo. I mean that we tried to set
$_COOKIE['ubercart_redirect'] = array('this', 'that');. You just can't do that, so we need two cookies, not one.Comment #14
patoh commentedStill doesnt redirect. The cookie is now storing the information but its not redirecting to previous domain when i type the TLD. is there something am missing? Been lookin at the code am gettng nothin..
Comment #15
agentrickardThe redirect will only fire if your cookie is more than 12 hours old and your math is backwards ;-).
You changed the code between comment 3 and comment 5.
Comment #16
patoh commentedso if i use - (12 * 60 * 60) that will mean if the cookie is less than 12 hrs old. do the redirect.. changing and testing now.
Comment #17
patoh commentedtake a look at the url http://kazijob.com/ look at the array. still not working as expected. nakuru.kazijob.com stores the cookie but thats it. :(
Comment #18
agentrickardNO minus means MORE than 12 hours old. $time here is a Unix timestamp, in seconds since 1970. Smaller values are in the past.
You want to force it to run, set it to 10 seconds and wait for an infinite loop:
Comment #19
patoh commentedAlso.. i have noticed that the cookies are expiring at the end of the session hence a new one is created on page load and killed on browser close.. am thinking if we can give the cookie an expiry timestamp, it will be able to redirect. what do yu think?
Comment #20
agentrickardMakes sense. But that's a programming issue outside my scope for support.
Feel free to post back when you finish working code.
Comment #21
patoh commentedi have goin round the code over the weekend and among the issue for the timestamp not working i also suspect the function ubercookie_get_my_cookie() is not being called to action. i tried to echo something from the function and it doesnt show anything. any insight on this? Thanx
Comment #22
agentrickardComment #23
mas0h commentedAny update on this? or a working code?