472,328 Members | 1,056 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

Browser Cookie Set/Get Issue

We are using Cookies in our application to track user session. It
works 95% but fails in occations. We could not find any pattern for
this. Below is the code to Set and Get cookies. In the occations when
it fails, we get nothing in getCookie as if cookie is not set. We
verified Browswer Setting and all of them accept cookies. We try to
find a pattern with Broswer types/versions and OS types/versions but
could not come with a pattern.

This happens on those particular PC. The same user might be able to
login by logging in from different PC. So far no clue on what could be
the error. Any suggestion on where to look at.


<Begin: Perl Code to Set/Get Cookie Cookie Name: CSSession>
sub setCookie
my $name = $_[0] ;
my $value = $_[1] ;
my $Time = $_[2] ;
my %MonthNames = (1=>"Jan", 2=>"Feb", 3=>"Mar", 4=>"Apr",
5=>"May", 6=>"Jun", 7=>"Jul", 8=>"Aug", 9=>"Sep", 10=>"Oct",
11=>"Nov", 12=>"Dec") ;
my %Wdays = (0=>"Sunday", 1=>"Monday", 2=>"Tuesday",
3=>"Wednesday", 4=>"Thursday", 5=>"Friday", 6=>"Saturday") ;
my $secure = " secure" ;
my $seconds = time() + ($Time*60) ;
my @GMtime = gmtime($seconds) ;
my $Cyear = $GMtime[5] + 1900 ;
my $Cmonth = $GMtime[4] + 1 ;
my $expiration = sprintf("$Wdays{$GMtime[6]}, %02d-$MonthNames
{$Cmonth}-%02d %02d:%02d:%02d GMT", $GMtime[3], $Cyear, $GMtime[2],
$GMtime[1], $GMtime[0]) ;
my $path = "" ;
my $domain = "" ;
my $cookiestr = "Set-Cookie: $name=$value; expires=$expiration" ;
return "$cookiestr" ;
sub getCookie
my ($GlobalPtr) = @_ ;
my (@rawCookies) = split (/; /,$ENV{'HTTP_COOKIE'});
$GlobalPtr->{'INCOOKIE'} = $ENV{'HTTP_COOKIE'} ;
($key, $val) = split (/=/,$_);
$GlobalPtr->{$key} = $val;
<End: Perl Code to Set/Get Cookie>

<JavaScript function to verify the cookie properties of browser>
<script language="JavaScript1.3">
function GetSessionID (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getSessionVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
return null;
function getSessionVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
function focusAt(formname, felement){
function CheckSettings() {
var agt = navigator.userAgent.toLowerCase();
var appname = navigator.appName.toLowerCase() ;
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var SessionID = GetSessionID('CSSession') ;
var clen = 0 ;
if(SessionID != null) {
clen = SessionID.length ;
else {
if(RedirectFlag == 0) {
document.location.href="__nocookieurl__" ;
Jul 19 '05 #1
0 3824

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Theo | last post by:
Question for the group The authentication system for the site Im working on seems to function properly and all is good. A session keeps track of...
by: Nancy Drew | last post by:
hi all i'm trying to keep users from being able to login to a site twice at the same time. everytime a user does a login, i stick their userID...
by: David Lozzi | last post by:
Hello All, I am having an issue with thus far one computer on my client's web site. If the user loads the shopping cart and then closes all...
by: Ben | last post by:
Hi, I'm sending out a session cookie. That is a cookie that has no expiration date. When I surf through the site, no problems, but if I close the...
by: Tina | last post by:
When I use Request.Browser.Cookies I always get true returned. Even when the browser has cookie acceptance turned off. Why? Thanks, T
by: Niko | last post by:
Hi I have a big problem with some browser setting wrong ASP.NETSessionid in a cookie, and the result is that asp.net 1.1 always assigns new...
by: etnaelk | last post by:
Hi all, I have a real bugger of a problem that I just haven't been able to figure out. I am working on writing my own proxy server in C# using...
by: bgold12 | last post by:
When a user logs onto my site, I set some session data using php: .... session_start(); .... $_SESSION = 'value'; .... From what I...
by: jodleren | last post by:
Hi I did not notice. A system I have made, seems on one server to keep the $_SESSION even when the browser has been closed... How can I avoid...
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...

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.