Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Cookies over secure server

Status
Not open for further replies.

Dynamo3209

Programmer
Joined
Jan 2, 2003
Messages
57
Location
US
Hi,
I am facing a strange problem while setting cookies in php.
If I try setting cookies over a secure server ( cookies are not at all set in the browser.
However if I use cookies are set and I am able to get the desired output.
I am not sure if the cookies need to be set in a different manner or some other things need to be taken care of while setting the cookies over an https server.
I am using PHP 4.1.2 version.
Appreciate any help on this.

Thanks,
Mohit.
 
To the best of my knowledge, the manner in which you set cookies does not differ between HTTP and HTTPS.

How are you setting the cookies and testing for the presence of the cookies in HTTPS?



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Hi slepnir,
I am setting the cookies using setcookie function and checking with
if (isset($_COOKIE['cookiename']))

Thanks,
Mohit
 
Are you doing this all in the same script? Under the PHP manual entry on setcookie(), there is section titled "Common Pitfalls", which reads, in part:
Cookies will not become visible until the next loading of a page that the cookie should be visible for.




Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Nope I am refreshing the page so that the cookies are visibile
before checking for the cookies
 
setting 2 cookies one cookie stores the username and the second cookie stores the userid those are used for different purposes.
 
None of the cookies are set over HTTPS however the same code runs perfectly well over HTTP.
 
when I point my browser to the cookies are not set
However if I point my browser to the script runs perfectly ok.
I make no changes in the script. The only change I make is instead of pointing to https directory I point server to http directory I have duplicated the files on both the directories i.e. secure and non-secure.
 
Perhaps I'm not being explicit enough.

When you are checking for the presence of cookies that were set by a script, are you performing the check within the same domain name in which you set the cookie? For example, if you set the cookie at secure.domain.tld, do you check for the presence of the cookie at secure.domain.tld.

Cookies are domain-specific.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top