Solved

ASP Cookies

Posted on 1998-10-22
4
146 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
  • 2
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
sybe earned 30 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now