Solved

ASP Cookies

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Python 2.7 - French characters 6 59
change home folder path 4 44
AutoHotkey ActiveX Component Error 8 71
Batch script to move disabled user accounts to different OU 5 65
This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
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)
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

15 Experts available now in Live!

Get 1:1 Help Now