output every session in separate text file

Posted on 2012-08-21
Last Modified: 2012-08-21
Hi experts,

I need to save every session's data submitted by a form in separate text files. This is what i'm using now to save it in the same file:

$fp = fopen("data.txt","a");
fputs($fp, $data);

Please help.
Question by:gloriaewold41
    LVL 34

    Accepted Solution

    Try changing:
    $fp = fopen("data.txt","a");
    $fp = fopen("data-".session_id().".txt","a");

    Author Closing Comment

    It works. Thanks.
    LVL 49

    Expert Comment

    by:Julian Hansen
    Alternatively you can do it in one line like this

    file_put_contents('session-' . session_id() . '.txt', $data);

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    737 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

    19 Experts available now in Live!

    Get 1:1 Help Now