Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Cookie Reading Problem in a PopUp Window

Posted on 2009-05-12
11
Medium Priority
?
197 Views
Last Modified: 2012-06-27
HI Folks,

I am setting a login Cookie which stores fine. But I am trying to read the same cookie in a PopUp window within the same browser session.

I am unable to do that. Any Ideas on how to pass the cookie value to a popup window within the same browser session.

Thanks

RG
Main Browser Window
	Response.Cookies ("Cusername") = Request.Form("login")
		
	Response.Cookies ("Cusername").Expires = dateadd("H",1,now) 
        Response.Redirect("default.asp") ' Go to the main page 
 
From the PopUp Window
 
vUserName = Request.Cookies("Cusername") ' Returns Blank

Open in new window

0
Comment
Question by:rgarimella
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
11 Comments
 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24365180
try this (This is what I use)

<%
' name of the cookie in example is called: Carrzkiss
strUserName = Request.Cookies("Carrzkiss")("Cusername")
If Request.Cookies("Carrzkiss")("Cusername") = "" Then
      Response.Redirect"login/index.asp?Message=You_are_Not_Logged_In"
End If
%>

Carrzkiss

0
 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24365198
Is the name of your cookie    cusername?
Then that would change this to:
User = Being the name of the user logged in.

<%
' name of the cookie in example is called: Carrzkiss
strUserName = Request.Cookies("Carrzkiss")("User")
If Request.Cookies("Carrzkiss")("User") = "" Then
      Response.Redirect"login/index.asp?Message=You_are_Not_Logged_In"
End If
%>

Carrzkiss
0
 

Author Comment

by:rgarimella
ID: 24365319
Hi,

I dont have problems logging in. The problem is reading the value of  Cookie "Cusername" from a popup window, within the same browser session.

The Cookie is setting fine, but unable to read from popup window
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24365442
do this
<%
strUserName = Request.Cookies("Carrzkiss")("User")
%>

<%-strUserName%>
0
 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24365460
make sure that you are also reading the file that "READS" the cookie.
Make sure that it is an <!--#include file="cookie-reader.asp"-->
If you are not reading the file within' the popup then it would explain as to why it is not reading it.

Popup Window or no Popup window.
It will still read the cookie as long as all refrences are made properly

Good Luck
Carrzkiss
0
 

Author Comment

by:rgarimella
ID: 24365501
Yes,

I did this strUserName = Request.Cookies("Carrzkiss")("User")

But still returns blank

But if I call the page directly inside a browser window instead of a Popup it shows the correct value

0
 

Author Comment

by:rgarimella
ID: 24365527
Could you explain a little bit  about

Make sure that it is an <!--#include file="cookie-reader.asp"-->

Right now I am directly reading the cookie value from a popup
0
 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24365712
can you make me up a demo of what you are doing?
This way I can have a look at it to see where the issue is?
0
 

Author Comment

by:rgarimella
ID: 24365772
I have 3 files,

login_db.asp (cookie is set fine)

Response.Cookies("ckLogin")("Cusername") = Request.Form("login")

2nd
I have a html file which has a button for window.open

which opens the 3rd file add.asp which has to read the cookie

if I directly open add.asp the cookie is read fine, but when I open from the HTML file in a poup window the cookie is not read

vUserName = Request.Cookies ("ckLogin")("Cusername") ' Returns Blank
0
 
LVL 31

Accepted Solution

by:
Wayne Barron earned 2000 total points
ID: 24370712
I just ran a test with a Popup Window using the code that I supplied for you above and it worked without any issue.

This is the code from my Demo Cookie Membership Login Demo that I have up here on EE

(This works without an issue)

Carrzkiss
IsLoggedIn.asp
=======================
<%
strUserName = Request.Cookies("carrzkissCookieDemo")("User")
If strUserName = "" Then
	Response.Redirect"login.asp?Message=You_are_Not_Logged_In"
End If
%>
 
============
in the popup window
<!--#inlcude file="IsLoggedIn.asp"-->
 
Display
<%=strUserName%>

Open in new window

0
 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24379896
did all work out?
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question