473,513 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

my set_cookie() function is not working

2 New Member
Hie....my set_cookie function is not working. I dont know why it is happening as there is no error also...i am setting it through javascript.......

Expand|Select|Wrap|Line Numbers
  1. var live_element;
  2. function fokus(ele,path) 
  3. {
  4.     //alert(ele);alert(path);return false;
  5.     live_element = ele;
  6.     //alert(live_element.id);    //LIKE C_NAME
  7.  
  8.     if(Get_Cookie('live_element'))     //Go to 873
  9.     {
  10.         Delete_Cookie( 'live_element');
  11.     }
  12.     Set_Cookie( 'live_element', live_element.id,'',path,'','' );
  13.     //Set_Cookie( name, value, expires, path, domain, secure )
  14. }
  15.  
  16. function Set_Cookie( name, value, expires, path, domain, secure ) 
  17. {
  18.  
  19. // set time, it's in milliseconds
  20. var today = new Date();
  21. today.setTime( today.getTime() );
  22.  
  23. /*
  24. if the expires variable is set, make the correct 
  25. expires time, the current script below will set 
  26. it for x number of days, to make it for hours, 
  27. delete * 24, for minutes, delete * 60 * 24
  28. */
  29. if ( expires )
  30. {
  31. expires = expires * 1000 * 60 * 60 * 24;
  32. }
  33. var expires_date = new Date( today.getTime() + (expires) );
  34.  
  35. document.cookie = name + "=" +escape( value ) +
  36. ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
  37. ( ( path ) ? ";path=" + path : "" ) + 
  38. ( ( domain ) ? ";domain=" + domain : "" ) +
  39. ( ( secure ) ? ";secure" : "" );
  40.  
  41. }
  42.  
Here , the 'live_element' named cookie is not generated...what could be the problem?
Aug 27 '09 #1
2 2330
gits
5,390 Recognized Expert Moderator Expert
when you pass '' as the expires param then your function will produce an invalid date for expires_date ... you could fix that with an adapted condition:

Expand|Select|Wrap|Line Numbers
  1. if ( expires ) {
  2.     expires = expires * 1000 * 60 * 60 * 24;
  3. } else {
  4.     expires = 0;
  5. }
  6.  
kind regards
Aug 30 '09 #2
riddhibhatia
2 New Member
yap.....i'll try this one and see.....
Sep 3 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2145
by: amit kumar | last post by:
I am calling a function which returns pointer to a map. The declaration of the map is map<int,vectxyz*>. vectxyz is a vector containing pointer to a class xyz. For map<int,vectxyz*>* p1 In the...
39
6481
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
1
8194
by: Julie May | last post by:
I have 90% of my function working and I know to get the next 10% it is justa matter of getting the quotations and the escaping quotations correct. Here is the portion that does work: <working...
0
2337
by: serkan | last post by:
Guys, I am trying to get this password reset functionality wor for me but I am not successful at all. Please somebody help me. I get "Your password could not be reset - please try again later" so I...
1
18835
by: den2005 | last post by:
Hi everybody, I am confused and still looking why this codes is not working. Can anyone notice or know why this code is not working? Thanks in advance. Code working: <form id="form1"...
10
6926
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK...
3
2901
by: BibhuAshish | last post by:
Hello guys i have one function which converts the ip/netmask into networkid/netmask and also it shows the message to user that his ip is changed to network id. but that function is working in...
7
16253
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am using this code to get groups for a user and getting a error (5) on the GetAuthorizationGroups() function . There are two domains. This function works on the local domain but does not work...
0
3043
by: über | last post by:
#!/usr/bin/perl use LWP::UserAgent; use HTTP::Cookies; use strict; my $ua = LWP::UserAgent->new(); my $cookie_jar = HTTP::Cookies->new(); $ua->cookie_jar( $cookie_jar );...
0
7157
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7379
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7521
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5084
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.