How to find that cookie set in browsers or not?

When you code with javascript and set cookies using the javascript code, now when you test it then you did not get the result, all code are correct but still you do not get the result. if you want to debug this issue then you need to check that cookie is actual created or not, now the question is how to see the cookies are created or not. below is the steps to see the cookies are created or not.

1) Go to main menu and click on tools.
2) Select Options from the menu.
3) One pop-up will opne, now in this pop-up see at the top icons and select Privacy icon.
4) in the History fieldset you will see the drop-down with remember history.
5) Select use custom settings for history.
6) now click on the show cookies button.
7) again new pop-up will open and its give folder tree structure, in that structure find the domain name for which you search cookies.
8) all cookies are store in that, so you can check that cookie is set or not.

set cross-subdomain cookie with javascript

How to set cross-subdomain cookie with javascript?

As we mention that using php we can set the cookie for cross-subdomain, we can also set the cookie in javascript as well. when we are working on the sub-domain and we need cross-subdomain cookie in php then we also need cross-subdomain cookie in javascript.

First i explain how to set cookie in the javascript because people are not aware that we how to set cookie in javascript. using JavaScript, you can create cookie and retrieve value from that cookie.

document.cookie = ‘cookiename=’ + cookievalue+ ‘,expires=’ + expirydate.toGMTString();

Here cookiename is the name of cookie and the cookievalue is the value which you need to store in the cookie, expires is the expiry data of the cookie.

Now, if you need to set cross-subdomain cookie then use the below code

document.cookie = name+”=”+value+”expires=”+date.toGMTString()+”; path=/;”;

Here i mention 2 more things which is not available in the first one, this is path and domain. path is the folder path where you need to store the cookie and the domain is the domain name for which you need to set the cookie, please look carefully that i set value in the domain, here first dot(.) is required if you want to set it for cross- subdomain, if you do not set it then it will not work for cross-subdomain.

set session to access on main domain and sub-domain, session access to all sub-domain

if you are creating sub-domain for modules and want to use the same session across all subdomains then you need to setup the configuration.

if you want to set session to access on main domain and sub-domain, that means session access to all sub-domain, i mean sessions across subdomains.

There is three way to set the configuration for this.

1) open php.ini file and search session.cookie_domain, set the main domain there without www, for example your main domain is then you need to set session.cookie_domain =
2) set using .htaccess file. set php_value session.cookie_domain in your .htaccess file.
3) using php_ini function you can set. ini_set(‘session.cookie_domain’,’’ ).

I think there is not any easy way then above three, enjoy the multiple domains……

How to set Cookie in php?

when you are working with the php, you need to careful in the cookies and sessions, i show you with example that how to set cookie in php.

PHP provide the setcookie() function to set the cookie.


setcookie(cookie name,cookie value,cookie expire date,cookie path,cookie domain,secure)

1) cookie name: This is Required and you can set any name of the cookie.
2) cookie value: This is Required and you can set value of the cookie
3) cookie expire date: This is Optional and you can set when the cookie expires. you can set the time for cookie. if you need to set cookie for 30 days then you set time()+3600*24*30. your cookie will expire when the session end if you do not set this parameter.
4) cookie path: This is Optional Parameter. when you set this parameter its define server path of the cookie, If you need the cookie for entire domain then you set it to “/”. If set to “/example/”, the cookie will only be available within the example directory and all sub-directories of example folder. current directory is the default value for the cookie, if you not set.
5) cookie domain: This is Optional Parameter. Specifies the domain name of the cookie. if you need to set it for main domain and all sub-domain then you can set this as if you set then its available in the only.
6) secure: This is Optional Parameter. This is define for the cookie that should transmitted over a secure HTTPS connection only. if you set it TRUE that define that the cookie will only be set if a secure connection exists. Default value for this parameter is FALSE.


setcookie(‘cookie_user_id’,$_SESSION[“user_id”],time() + (86400 * 365),’/’,’’);