Solved

ASP Cookies

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to dynamically set the form action using jQuery.

630 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