• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the magic cookie value?

 
joel smither
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my urlybird dev exam project, there is something called a "magic cookie" value in the database file.

What is the purpose fo this piece of information, am I exprected to do something with it programmatically?

Thanks in advance.
 
Eric Chang
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a previous thread about this here: http://www.coderanch.com/t/186578/java-developer-SCJD/certification/Verify-database-format

You might find it useful.
 
joel smither
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still not clear on what should be done with this cookie value.

I get the impression from reading previous threads that the cookie value is used to determine that a file is valid database file or not.

So what should I do in my application? Does every valid database file use the SAME cookie? If so I guess I could check to make sure the file has the appropriate cookie value when I first open it up for access. Is this the right thing to do?
 
Eric Chang
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do whatever you want with it. There is no MUST to do anything with the cookie value. Some people (like me) have decided to hardcode it in and use it to verify a database file. I'm sure there are other people who chose not to do anything with it (I was about to do that, but I figured one line of extra code couldn't hurt).
 
Sean Gildea
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just verified it was equal to 00 00 in hex , since those are the first 2 hex numbers in the file.


 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11865
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

If you are not already aware of this, there are multiple assignments, and multiple versions of the assignments. Some of the variations in the versions of the assignments do include changes to the database structure. For example, some databases have a two-byte "deleted" flag, while others have a single-byte "deleted" flag. There are many more differences as well.

So even if two candidates are working on the contractors assignment, the database formats may be completely different. In such a case, though, the cookie values will be different.

I personally feel that you must validate the cookie value, as not all the database structural changes will be catered for in the meta data.

Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic