Solved

ASP Cookies

Posted on 1998-10-22
4
148 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
inactive users 13 78
Google  (Get  Users Email) 2 125
Facebook React and SyntheticEvents 6 66
Looking for a program that deletes all files of same size 18 63
In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

773 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