VuGen code snippet for adjusting cookies
#include "time.h"
time_t timer;
char buffer[26];
struct tm* tm_info;
time(&timer);
tm_info = localtime(&timer);
lr_message("timer: %ld",timer);
//16–Nov–2016 23:12:40 GMT;
//strftime(buffer, 26, "%Y-%m-%d %H:%M:%S", tm_info);
strftime(buffer, 26, "%d-%b-%Y %H:%M:%S GMT", tm_info);
lr_message(buffer);
timer = timer + 86400; //add 24 hours
tm_info = localtime(&timer);
lr_message("timer: %ld",timer);
//16–Nov–2016 23:12:40 GMT;
//strftime(buffer, 26, "%Y-%m-%d %H:%M:%S", tm_info);
strftime(buffer, 26, "%d-%b-%Y %H:%M:%S GMT", tm_info);
lr_message(buffer);
web_reg_save_param_ex("ParamName=CS_Identity","LB=CS_Identity=","RB=;",SEARCH_FILTERS,"Scope=Headers",LAST);
lr_message("CS_Identity=%s",lr_eval_string("{CS_Identity}"));
web_cache_cleanup();
lr_message("CS_Identity=%s",lr_eval_string("{CS_Identity}"));
sprintf(strtemp1,"CS_Identity=%s; path=/; expires=Wednesday, %s; domain=perf.server.com",lr_eval_string("{CS_Identity}"),buffer);
lr_output_message("%s", strtemp1);
sprintf(strtemp2,"CS_Identity=%s; path=/; expires=Wednesday, %s; domain=stage.server.com",lr_eval_string("{CS_Identity}"),buffer);
lr_output_message("%s", strtemp2);
//
These cookie details were first seen in full in a Fiddler trace response from one of our
calls, inside a 'Set-Cookie:' statement:
//web_add_cookie ("CS_Identity=eyJkaXNwbGF5TmFtZSI6Ik1hcmsiLCJn ZW5kZXIixxxxxxxFIiwiYWdlIjoiMzQiLCJ1c2VySWQiOiI2ZWE4MT UwNy01NmUxLTRjOWQtYTJjMS0wZDUwYzhiZWY4YzUiLCJ0eXBlIjoiQzQi LCJyZW1lbWJlck1lIjoiZmFsc2UiLCJjcmVhdGVkIjoiMTQ3OTIwOTU1MD E3MiIsImhhc2giOiJiVjE2V2pVbmtubEwydWNJSThhUzVnIiwixxxxxx Vzc0NhcHR1cmVkIjoidHJ1ZSJ9; path=/; expires=Wednesday, 16–Nov–2016 23:12:40 GMT; domain=perf.server.com");
web_remove_cookie("CS_Identity"); //This removes the named cookie from all domains
web_add_cookie (strtemp1);
Note: To get the full date in, with the DAY as well, I had to adjust the above slightly:
char buffer2[52];
strftime(buffer2, 52, "%A, %d-%b-%Y %H:%M:%S GMT", tm_info);
lr_message("Update:");
lr_message(buffer2);
Output is now:
timer: 1479379838
17-Nov-2016 10:50:38 GMT
timer: 1479466238
18-Nov-2016 10:50:38 GMT
Update:
Friday, 18-Nov-2016 10:50:38 GMT
( I got format info from here:
http://apidock.com/ruby/DateTime/strftime )