Tuesday, 15 July 2014

Why can I not set cross-subdomain cookies via javascript or php? -



Why can I not set cross-subdomain cookies via javascript or php? -

i trying both in javascript , in php set cookies work cross-domain.

in php:

ini_set('session.cookie_domain', '.example.com' ); session_set_cookie_params(60*60,"/",".example.com",false,false);

in javascript:

document.cookie = 'coo=21c4o2fnb2et aqj256; expires=sun feb 01 2015 23:40:16 gmt-0500 (est); path=/;domain=.example.com;'

in .htaccess:

php_value session.cookie_domain .example.com

in php.ini:

session.cookie_domain = ".example.com"

in php response, get:

phpsessid=togp8kh3ehst2iuf4t3egll7p0; expires=sun, 02-nov-2014 04:43:25 gmt; path=/; domain=.example.com

so, php response looks me, browser stores no cookies, both javascript , php. cookies work on single subdomain, site requesting cookie-required info different subdomain, i'd cookies work entire domain.

i think reply (duplicated) question:

share cookie between subdomain , domain

the trick on setting cookie higher domain possible, example.com, not .example.com (which not valid)

javascript php cookies

No comments:

Post a Comment