Search This Blog

Thursday, September 6, 2012

Define cookie path to access it everywhere in the domain

Sometimes programmers want their cookie variable available to all the pages in the domain but they don’t specify the cookie path. To make the cookie variable in all the pages in the domain one should set the cookie as below–setcookie(name of the variable,value of the cookie variable,expired time of cookie,path)the path should be “/”. If you do this way the cookie should be available all the way to the domain.
Example code : setcookie(“Name”,”Fuad”,time()+3600*24,”/”)

1 comment:

  1. Great discussion.Can you write some thing about Session.It will help us for using session in our web application.

    ReplyDelete