title: Got Solution How to store the cookies in login and delete the cookies in logout action
body: <pre><code>My Problem is solved
  </code></pre>
  
  <p>I am doing an application that is getting cookies from server side. I want to store the cookies and delete the cookies at logout function but I don't know how to do this.
  Based on this cookies my app has to show some additional benefits to the user so I want to save this cookies.
  This is login request:</p>
  
  <pre><code>- (IBAction)enterButtonAction:(id)sender {
          NSString *post =[NSString stringWithFormat:@"user[email]=%@&amp;user[password]=%@",userNameTF.text,passWordTF.text];
          NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
          NSString *postLength = [NSString stringWithFormat:@"%lu",(unsigned long)postData.length];
  
          NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
  
  
           [request setURL:[NSURL URLWithString:url]];
          [request setHTTPMethod:@"POST"];
          [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
          [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
          [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
          [request setHTTPBody:postData];
          NSURLConnection * connection = [NSURLConnection connectionWithRequest:request delegate:self];
          if (connection != nil) {
              NSLog(@"Connection Successfull");
              self.responseData = [NSMutableData alloc];
              [connection start];
          }else {
              NSLog(@"Failed");
          }
  
  
      }
  }
  -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
  {
      [self.responseData appendData:data];
  }
  -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
  {
      [self.responseData setLength:0];
  }
  -(void)connectionDidFinishLoading:(NSURLConnection *)connection
  {
      NSError * parseError = nil;
      NSMutableDictionary * _jsonDictionary = [NSJSONSerialization JSONObjectWithData:self.responseData options:kNilOptions error:&amp;parseError];
      NSLog(@"%@",_jsonDictionary);
      NSString * roleString = [_jsonDictionary objectForKey:@"role"];
  
      if ([roleString isEqualToString:@"user"]) {
          UIStoryboard * storyBD = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
          UITabBarController * obj = [storyBD instantiateViewControllerWithIdentifier:@"tab"];
          [self.navigationController pushViewController:obj animated:YES];
      }
      else {
          [self alertStatus:@"Please Enter 'Correct Email &amp; Password'" :nil];
      }
  
  }
  </code></pre>
  
  <p>//// Solution is this one it is working now very fine there is no need to store or delete the cookies every thing will handle this code </p>
  
  <pre><code>NSString *post =[NSString stringWithFormat:@"user[email]=%@&amp;user[password]=%@",userNameTF.text,passWordTF.text];
          NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
          NSString *postLength = [NSString stringWithFormat:@"%lu",(unsigned long)postData.length];
          NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
          [request setValue:@"myCookie" forHTTPHeaderField:@"Set-cookie"];
          [request setURL:[NSURL URLWithString:url]];
          [request setHTTPMethod:@"POST"];
          [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
          [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
          [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
          [request setHTTPBody:postData];
          NSDictionary *cookieProperties = [NSDictionary dictionaryWithObjectsAndKeys:
                                            @"http://yourwebsite.com", NSHTTPCookieDomain,
                                            @"\\", NSHTTPCookiePath,
                                            @"myCookie", NSHTTPCookieName,
                                            @"1234", NSHTTPCookieValue,
                                            nil];
  
          NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:cookieProperties];
          NSArray* cookieArray = [NSArray arrayWithObject:cookie];
          NSDictionary * headers = [NSHTTPCookie requestHeaderFieldsWithCookies:cookieArray];
          [request setAllHTTPHeaderFields:headers];
          NSURLConnection * connection = [NSURLConnection connectionWithRequest:request delegate:self];
          if (connection != nil) {
              NSLog(@"Connection Successfull");
              self.responseData = [NSMutableData alloc];
              [connection start];
          }else {
              [sharedAppDelegate dismissGlobalHUD];
              NSLog(@"Failed");
          }
  </code></pre>