Using cookies to determine the last page visited

A

Anita C

Hi,
How cookies can be used to set and then determine the last page visited by a
person browsing a particular website ? Also the page last visited is loaded
in an iframe, so the page last visited inside a particular iframe is what
really needs to be determined. So when the application starts up the next
time, if the last page visited was admin.aspx inside frame IContent, then
show admin.aspx in Icontent or else show home.aspx. A code sample or a link
to the reqd. info. will be great.
Thanks in advance.
 
H

Hermit Dave

From MSDN sample code
HttpCookie MyCookie = new HttpCookie("LastVisit");
DateTime now = DateTime.Now;

MyCookie.Value = now.ToString();
MyCookie.Expires = now.AddHours(1);

Response.Cookies.Add(MyCookie);

Instead of writing time... write the URL

you need to write a user control and add the control to all the pages that
are loaded in the IContent frame. All the user control does is write the
cookie of the page visited
each page will over write the value written by the last one
set the default page for the IContent frame to home page.. make sure home
page has another code which does a check for that cookie... and if found...
get the value... and redirect to that page...

Not too bad is it ?

HD
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top