?
Solved

Cookie Reading Problem in a PopUp Window

Posted on 2009-05-12
11
Medium Priority
?
195 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

800 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