• IE里Cookie跨域不能读取

    1.页面里的COOKIE不能是浏览器进程的COOKIE(包括验证票和不设置超时时间的COOKIE),否则跨域会取不到.这点做跨域COOKIE的人比较少提到.不过实际上留意下几家大学做的方案,有细微的提到他们的验证模块里的COOKIE是有设置超时时间的.

    2.当利用IFRAME时,记得要在相应的动态页的页头添加一下P3P的信息,否则IE会自觉的把IFRAME框里的COOKIE给阻止掉,产生问题.本身不保存自然就取不到了.这个其实是FRAMESET和COOKIE的问题,用FRAME或者IFRAME都会遇到.

    3.测试时输出TRACE,会减少很多测试的工作量.

    只需要设置 P3P HTTP Header,在隐含 iframe 里面跨域设置 cookie 就可以成功。他们所用的内容是:

    P3P: CP=’CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR’

    ASP直接在头部加了头部申明,测试有效。
    <%Response.AddHeader "P3P", "CP=CAO PSA OUR"%>

    php的话,应该是如下写法:
    -PHP
    header('P3P: CP=CAO PSA OUR');

    ASP.NET的话
    通过在代码上加
    -C#
    Response.AddHeader("P3P", "CP=CAO PSA OUR");

    或者在Window服务中将ASP.NET State Service 启动。

    JSP:
    response.setHeader("P3P","CP=CAO PSA OUR")

    英语原文解析
    You can add a P3P compact policy header to your child content, and you can declare that no malicious actions are performed with the data of the user. If Internet Explorer detects a satisfactory policy, then Internet Explorer permits the cookie to be set.

    Visit the following MSDN Web site for a complete list of satisfactory and unsatisfactory policy codes:

    Privacy in Internet Explorer 6
    http://msdn.microsoft.com/workshop/security/privacy/overview/privacyie6.asp
    A simple compact policy that fulfills this criteria follows:

    P3P: CP=”CAO PSA OUR”

    This code sample shows that your site provides you access to your own contact information (CAO), that any analyzed data is only “pseudo-analyzed”, which means that the data is connected to your online persona and not to your physical identity (PSA), and that your data is not supplied to any outside agencies for those agencies to use (OUR).

    You can set this header if you use the Response.AddHeader method in an ASP page. In ASP.NET, you can use the Response.AppendHeader method. You can use the IIS Management Snap-In (inetmgr) to add to a static file.

    Follow these steps to add this header to a static file:

    1. Click Start, click Run, and then type inetmgr.
    2. In the left navigation page, click the appropriate file or directory in your Web site to which you want to add the header, right-click the file, and then click Properties.
    3. Click the HTTP Headers tab.
    4. In the Custom HTTP Headers group box, click Add.
    5. Type P3P for the header name, and then for the compact policy string, type CP=…, where “…” is the appropriate code for your compact policy.

    Alternatively, Internet Explorer users can modify their privacy settings so that they are prompted to accept third party content. The following steps show how to modify the privacy settings:

    1. Run Internet Explorer.
    2. Click Tools, and then click Internet Options.
    3. Click the Privacy tab, and then click Advanced.
    4. Click to select the Override automatic cookie handling check box.
    5. To allow ASP and ASP.NET session cookies to be set, click to select the Always allow session cookies check box.
    6. To receive a prompt for any type of third party cookie, click Prompt in the Third-party Cookies list.

  • ASP读写文本文件

    在ASP里,有一个FSO对象,File System Object,即文件系统对象。我们可以使用它来从文本文件中读取数据,或者将信息写入文本文件中。

    定义和用法

    OpenTextFile 方法打开指定的文件,并返回可用来访问此文件的 TextStream 对象。

    语法:

    FileSystemObject.OpenTextFile(fname,mode,create,format)
    参数 描述
    fname 必需的。要打开的文件的名称。
    mode 可选的。如何打开文件。

    • 1=ForReading – 打开文件用于读取数据。您无法向此文件写数据。
    • 2=ForWriting – 打开文件用于写数据。
    • 8=ForAppending – 打开文件,并向文件的末尾写数据。
    create 可选的。设置如果文件名不存在,是否创建新文件。True 指示可创建新文件,而 False 指示新文件不会被创建。False 是默认的。
    format 可选的。文件的格式。

    • 0=TristateFalse – 以 ASCII 打开文件。默认。
    • -1=TristateTrue – 以 Unicode 打开文件。
    • -2=TristateUseDefault – 使用系统默认格式打开文件。

    先来看一段代码:

    <%
    dim fs,f
    set fs=Server.CreateObject("Scripting.FileSystemObject")
    set f=fs.OpenTextFile(Server.MapPath("testread.txt"),8,true)
    f.WriteLine("This text will be added to the end of file")
    f.Close
    set f=Nothing
    set fs=Nothing
    %>

    上面的代码展示如何将一段文字写入到一个文本文件中。 下面我们再写一段程序,用ASP把它从文本文件中读出来,且看:

    <%
    dim fs,f,t,x
    set fs=Server.CreateObject("Scripting.FileSystemObject")
    set f=fs.CreateTextFile("c:\test.txt")
    f.write("Hello World!")
    f.close
    
    set t=fs.OpenTextFile("c:\test.txt",1,false)
    x=t.ReadAll
    t.close
    Response.Write("The text in the file is: " & x)
    %>

    这里使用了逐行读取的方法,将文本文件中的内容全部读取出来,保存到一个str变量中,ASP最后把str变量输出出来了。
    还一个方法叫readAll(),用它替换readLine()方法,表示,一次性把文本文件中的所有的内容都读出来,这时候当然就不需要循环了,大家可以自己写写看。
  • 地方团

    团购的最大亮点在于他能弥补类似淘宝、京东等商城无法提供生活化服务的缺陷。如果团购仅仅拼的是价格,那团购模式也不会被投资者如此看重了。
    从本地团购消费者的角度来讲,团购网站目前除了在一些大城市推广餐饮、娱乐服务外,对其他地区的大众推出的都是一些仅仅只有价格优势,而缺乏其他特色的产品。有些用户更需要的是一些本地商家、店家的打折优惠,对于这些需求,大的团购网站是无法满足他们的。地方团购网站正好弥补了这些不足,利用本地的地域优势,积极联系本地商家、店家,推出本地特色的团购产品和服务,这是行得通的。
    当我们的团购网站做出品牌知名度、用户量达到一定程度,你还怕没出路吗?无论是自己组建小团购运营还是将其出售给其他团购网站大佬,相信都是不错的选择。