+ Start a Discussion
TehNrdTehNrd 

What are the params for new Cookie creation?

The documentation for the new cookie class seems to fall a little short. I create a new cookie like this:

 

Cookie myCookie = new Cookie('counter','1',null,-1,false);

But I can't find any documenation on what these parameters are. Here is my best guess(name,value,?,?,isSecure). I assue one of the ? is some time of duration or expiration date. Are any of these optional?

 

Can someone enlighten me and perhaps update the documentation.

 

Thanks,

Jason

ChrisNoeChrisNoe

You're right, the documentation falls a little short here but the parameters are referenced in the comments section of the example code so I would go with that for now (Name, Value, Path, maxAge, isSecure).  I would assume all parameters are required but you can provide "null" for the path to store the cookie at the root.

 

 

// create a new cookie with name 'counter', an initial value of '1',   
    
// path 'null', maxAge '-1', and isSecure 'false'.   
    
    if (counter ==null) {
        counter = new Cookie('counter','1',null,-1,false);

 

 

TehNrdTehNrd

Thanks, I blew right past that. I assume an age of -1 means it is only good for the session.

ChrisNoeChrisNoe

You got it...

 

<0 = session cookie

0 = delete

>0 = valid time in seconds