Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP Cookies

Posted on 1998-10-22
4
Medium Priority
?
153 Views
Last Modified: 2013-12-25
I have inserted this code in the middle of an ASP script:

Response.Cookies("UserId") = User
Response.Cookies("UserId").Expires = Date + 30
Response.Cookies("UserId").Domain = "www.mydomain.com"
Response.Cookies("UserId").Path = "/"
Response.Cookies("UserId").Secure = TRUE

I haven't figured out why but it is giving me this error:

Response object error 'ASP 0156 : 80004005'
Header Error
/Scripts/default.asp, line 104

The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.

Does anyone know what could be causing this ?
0
Comment
Question by:AnitaP
[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
  • 2
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
sybe earned 90 total points
ID: 1829245
When you write a cookie in ASP, you must do that BEFORE any other HTML-output. So at the top of the page.
0
 

Author Comment

by:AnitaP
ID: 1829246
ok. If I put my cookie at the begining of my default.asp page then isn't it going to change everytime the client comes back to that same page or reloads it ?

What I mean is If I put this at the begining of my default.asp page :

User = Session.sessionID & now()
Session("UserID")

and then I access this page (default.asp) through another page, my Session("UserID") will contain another value. how can I prevent my session("UserID") from changing ?

The only time that I need to assign a new value is when the client accesses default.asp for the first time and in my last .asp file.
0
 
LVL 28

Expert Comment

by:sybe
ID: 1829247
Then use the global.asa for that

Sub Session_OnStart
 Session("UserId") = ....
End Sub

Sub Session_OnEnd
 Session("UserId") = ...
End Sub

The global.asa is always processed when an asp is called from that application.


0
 

Author Comment

by:AnitaP
ID: 1829248
thanks
0

Featured Post

Quick Start: DOCKER

Sometimes you just need a Quick Start on a topic in order to begin using it.. this is just what you need to know to get up and running with Docker!

Question has a verified solution.

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

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

670 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