473,587 Members | 2,496 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...wha t could be the problem?
Aug 27 '09 #1
2 2337
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
2150
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 called function, I am using p1->find(1) which is returning a valid iterator and not going to the end. I am returning p1 from the called function. ...
39
6507
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. When it completes, it can call a success, or a failure function. The names of these success, or failure functions will differ, and I'd like to know...
1
8200
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 code> -- Function: public.get_factory_ytd() CREATE or replace FUNCTION public.get_factory_ytd() RETURNS setof record AS' declare ytd_record record;...
0
2341
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 think the get_random_word function is not working right. Here are the scripts: This is the script after the user enters his/her userid. <?php ...
1
18845
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" runat="server"> <div> &nbsp;</div> <div>
10
6949
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 MyEnumWindowsProc(HWND hwnd, LPARAM lparam) {
3
2916
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 mozilla perfectly but not in IE. To check where is the fault i have written so many alert() but sometimes these are working. Please someone read my...
7
16287
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 on the other domain. Other functions work on the other domain like get all the users and get all the groups and I can validate users on the other...
0
3045
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 ); $cookie_jar->set_cookie( 1, # version 'username', # key
0
7923
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7852
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5719
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3845
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
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 we have to send another system
0
1192
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.