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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating cookies manually

Status
Not open for further replies.

sirugo

Programmer
Aug 1, 2000
162
SE
Is it possible to create and/or change cookie-data manually?
I mean: the cookie files seem to be plain text files.

I want to use an app that I wrote in C++ that sends the Netware username to a text file stored in the Cookies folder. When the browser runs a php script, the script looks for the cookie value which gives me the Netware username.

Can it be done?
 
Is your question, "Is it possible to programmatically edit a browser's cookie store?". Yes, it is.

Is the question "How do you do it by running a C++ app on the workstation?" apropos to this forum? No, it is not.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
My question contains "both" of these questions.
How can I make people here understand what my needs are if I don't ask both questions? The important thing is that you understand what I want to happen.
The C++ app is already ready to write in the Cookies folder. That is not a problem. But when I call the $_COOKIE - function after changing the content of the cookie file I get the same value of the cookie as before, or nothing at all. I also tried to open the cookie as a text file to change the cookie value, then saved it, reloaded the php page but with the same result.

Also - you might have another solution that more belongs here than anywhere else. How can I know that before asking?
 
Here's my two cents worth. If the cookie isn't changed in $_COOKIE, then the cookie hasn't changed.

The way I look at it, browsers store cookies in two places -- in memory and in the file. The "current" cookie set is stored in memory, and only those cookies that need to be stored between browser sessions are actually written to the file. This is how cookies that are supposed to expire at the end of a browser session are handled -- they simply are not written to the file.

From all this, it follows logically that if the browser is working from memory, the only time it would read the cookie file is the first time during a session that it goes to a site. All the rest of the time, it ignores the cookie store.

But you can test this:[ol][li]Go to a PHP script that sets a cookie, then to another PHP script that shows all cookies to verify the cookie was set.[/li][li]Shut down the browser[/li][li]Manipulate the browser's cookie store with your program[/li][li]Restart the browser and point it at the PHP script that shows cookies[/li][/ol]

If the cookies now change, my hypothesis above about browser cookie stores is correct and you'll have to do whatever it is you're trying to do another way, perhaps setting a cookie through a programmatically-created JavaScript file. But that is a question for another forum.

But you're manipulating a browser. That would be, in my opinion, a question for a forum on browser issues.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks, but now I found another way to work aroound this.

The C++ app opens the url silently in Explorer (without showing the window), then sets the cookie with a time limit. When the user decides to start Explorer he's already logged in to whatever.

It works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top