Php session

Hey everyone,
Lovin adobe muse, it has allowed me to start up an old project of mine. I ran into a problem however and I ope someone here can help me.
I have created a log in system using php and mysql. The problem I am having is that if I load another page on my site I lose my php session because I am unable to write session start at the very beginning of my page. My work around is to publish and then open it in dream weaver add the code and then upload to my site.....annoying to do. Does anyone know of another way to fix this problem? Does session_start() have to be at the very beginning? Thanks in advanced.

To use cookie-based sessions, session_start() must be called before outputing anything to the browser.
- http://php.net/manual/en/function.session-start.php
Also, I would like to mention that this is not the right place to put up a php based query as the community will be more interested in assisting you in the Muse related queries and be benefited from it in return. A better place infact would be something like php.net or stackoverflow.
Hope that helps.
- Abhishek Maurya

Similar Messages

  • OT: ending PHP sessions

    is there a way to run a script when a PHP session
    ends/closes? To do
    some cleanup?

    Alexander Ross wrote:
    > Yes ... but I'd like it saved ONLY for the duration of
    the user's
    > session. These images are being saved server-side, not
    on teh client's
    > machine
    That begs the question of why save the image in the first
    place.
    However, there are two approaches you can take:
    1. Ask the user to log out and use unlink() to remove the
    saved image as
    part of the logout process.
    2. Set up a scheduled task (cron job on a linux server) to
    delete all
    images that are more than two hours old, and run it once
    every 24 hours.
    Even if you do the first, you would probably need to
    implement the
    second one too, because you can't rely on everyone logging
    out.
    David Powers, Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • PHP session id?

    Hi,
    Sorry guys, this is more about php I suppose.
    I can login authenticating to a mysql database and create a
    php session and return a session_id() to flex but not sure what to
    do then! I suppose I can send this id from flex to every request I
    make to the server (URLLoader) but if there's multiple logged in
    users how do I know (php know) which session is which. Something
    like?:-
    if($my_session == session_id() )
    // do things
    But how does session_id() kow which session I'm talking
    about? Any help appreciated, I'm a newbie at flex and php. Thanks,
    Paul

    Hi,
    Sorry guys, this is more about php I suppose.
    I can login authenticating to a mysql database and create a
    php session and return a session_id() to flex but not sure what to
    do then! I suppose I can send this id from flex to every request I
    make to the server (URLLoader) but if there's multiple logged in
    users how do I know (php know) which session is which. Something
    like?:-
    if($my_session == session_id() )
    // do things
    But how does session_id() kow which session I'm talking
    about? Any help appreciated, I'm a newbie at flex and php. Thanks,
    Paul

  • [SOLVED] PHP sessions problem

    Since I don't often visit any other forum, someone here might be able to help
    I have a *very* basic web 'application' written which uses PHP sessions. For some reason, the session variable only exists in one page. Change to another and it disappears. Surely session variables are suppose to avoid this problem?
    Maybe I've got something entirely wrong. Any idea?
    Last edited by kourosh (2010-04-14 03:50:55)

    Well I've done a basic test:
    test.php
    <?php
    session_save_path("/home/a7049782/public_html/films/tmp");
    session_start();
    $session_path = session_save_path();
    $_SESSION['count']=1;
    ?>
    <html>
    <body>
    <?php echo "Count=" . $_SESSION['count']; ?>
    </body>
    </html>
    This sucessfully outputs 1
    Then another page:
    test2.php
    <?php
    if(isset($_SESSION['count']))
    echo "Count=" . $_SESSION['count'];
    else
    echo "No variable.";
    ?>
    Which outputs 'No variable.'
    (I've also tried this without defining a path, still the same result)

  • Php session Code and Dreamweaver Template

    I have a page that I created in dreamweaver.  It's a php page that has sessions, the file is from a Dreamweaver template that I created and am using.  However, when I update the master template file, the items before the Doctype keeps erasing.
    I have some php includes that are useful for post variables.  How can I tell dw not to delete those sections.  I can't create an editable region before the head? Is there a way?
    Thanks for you help.
    Sample Code:
    <?php
              include ("./includes/file1.inc");
              session_start();
              if(isset($_SESSION['code'])){
                        header("location:rsvp_file2.php");
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    I'm not clear in what you are saying?
    Are you saying you want to insert this block of php code on all the pages made from the master template file but when you insert it into the master template file and save the file the block of php code does not appear on any of the page made from the template?
    If that is the case then  do a 'find and replace' Find>Find and Replace. Find the doctype:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    and replace it in all the pages with:
    <?php
              include ("./includes/file1.inc");
              session_start();
              if(isset($_SESSION['code'])){
                        header("location:rsvp_file2.php");
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  • Beginner php session/user access question

    I'm using DreamWeaver MX 2004 (website uses php and mysql)
    and want users, when they login to view only their content. my sql
    table that connects to the login form has an id, name and password
    columns.
    a successful login is taken to a page with 3 links (page to
    update content, view content and add content). I'm think I need to
    carry the id from the login mysql table and think it goes in the
    code below. I'm just not sure where. of course, if i'm wrong,
    please point me in the correct direction.
    thanks!
    here's my code:
    <?php
    session_start();
    $MM_authorizedUsers = "2";
    $MM_donotCheckaccess = "false";
    // *** Restrict Access To Page: Grant or deny access to this
    page
    function isAuthorized($strUsers, $strGroups, $UserName,
    $UserGroup) {
    // For security, start by assuming the visitor is NOT
    authorized.
    $isValid = False;
    // When a visitor has logged into this site, the Session
    variable MM_Username set equal to their username.
    // Therefore, we know that a user is NOT logged in if that
    Session variable is blank.
    if (!empty($UserName)) {
    // Besides being logged in, you may restrict access to only
    certain users based on an ID established when they login.
    // Parse the strings into arrays.
    $arrUsers = Explode(",", $strUsers);
    $arrGroups = Explode(",", $strGroups);
    if (in_array($UserName, $arrUsers)) {
    $isValid = true;
    // Or, you may restrict access to only certain users based
    on their username.
    if (in_array($UserGroup, $arrGroups)) {
    $isValid = true;
    if (($strUsers == "") && false) {
    $isValid = true;
    return $isValid;
    $MM_restrictGoTo = "_login.php";
    if (!((isset($_SESSION['MM_Username'])) &&
    (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'],
    $_SESSION['MM_UserGroup'])))) {
    $MM_qsChar = "?";
    $MM_referrer = $_SERVER['PHP_SELF'];
    if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
    if (isset($QUERY_STRING) && strlen($QUERY_STRING)
    > 0)
    $MM_referrer .= "?" . $QUERY_STRING;
    $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar .
    "accesscheck=" . urlencode($MM_referrer);
    header("Location: ". $MM_restrictGoTo);
    exit;
    ?>
    <?php
    mysql_select_db($database_midnightnet, $midnightnet);
    $query_Recordset1 = "SELECT * FROM trs_admin";
    $Recordset1 = mysql_query($query_Recordset1, $midnightnet) or
    die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>

    MM_Username is the default session that Dreamweaver users for
    its login routine. What ever name the user logins in as
    [email protected], bob, Iamgreat443 etc is what is carried thru in
    that session variable. I always make the users use emails
    personally. If you to go the Binding tab > + > Session
    Variable type in MM_Username for Name it will create the session
    variable in your binding window so you can access it the recordset
    dialogs. You can then filter your user info on that session
    variable for any database you have ID'd your users in. Hope this
    helps

  • Quick question about PHP sessions and Air app

    Could someone clear this up for me?
    My air app makes html requests to php scripts, php login, search etc. I've been advised to use sessions in the php scripts to ensure each request to a script is done by a logged in user.
    So is the session identifier stored automatically by air somewhere, similar to a cookie in a browser?

    4.4.1 is indeed the version of php in 10.4.6, but it's also the version of php that's running on my 10.3.9 server. You can execute php -v on your server to see which version you've got, but it seems unlikely that it's a version other than 4.4.1 if you haven't updated it yourself. Are there security updates you haven't applied?

  • How to store php sessions using memcached and unix socket

    I am running Arch linux with systemd, nginx, and php with php-fpm. I am trying (and failing) to configure memcached to store sessions using a unix socket. I have memcached installed and active, however, I am unable to disable networking. I added the following line to /etc/conf.d/memcached
    MEMCACHED_ARGS="-s unix:///tmp/memcached.sock -a 666"
    I also tried:
    MEMCACHED_ARGS="-s /tmp/memcached.sock -a 666"
    MEMCACHED_ARGS="-s unix:/tmp/memcached.sock -a 666"
    when I restart memcached I always get:
    memcached.service - Memcached Daemon
              Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled)
              Active: active (running) since Sat 2013-01-19 17:41:15 PST; 5min ago
            Main PID: 773 (memcached)
              CGroup: name=systemd:/system/memcached.service
                      └─773 /usr/bin/memcached -l 127.0.0.1
    when I run php script with sessions php error log shows (not surprisingly):
    [19-Jan-2013 16:46:45 America/Los_Angeles] PHP Warning:  Unknown: Failed to write session data (memcached). Please verify that the current setting of session.save_path is correct (unix:/tmp/memcached.sock) in Unknown on line 0
    I also installed the php-memcached package but I don't what it does or how to get it going. I uncommented the following line in /etc/php/conf.d/memcached.ini:
    extension=memcached.so
    but that didn't change anything.
    Any insights or suggestions would be greatly appreciated.

    Look at this link -http://odiexperts.com/getting-one-or-several-unknown-files-from-a-directory
    change the command to fetch the ls command and write into File and then using either java or jython break the data and fetch the file name and date and insert into log table.
    (or)
    you can use the os.system command and get the complete ls command into string and then process and insert it.
    Let us know if you need any other help.

  • Help with php session variables

    I am using Dreamweaver 8 to set up a dynamic app with PHP and
    MySQL. I want the code that the user logs in with ('UPN') to be
    stored as a session variable so that recordsets on subsequent pages
    can be set to display personalised data.
    I have set the session variable like this: $_SESSION['UPN'] =
    'UPN' (UPN is the name of the form textfield, also set as the
    username for logging in)
    On the data page, I have called the variable like this:
    $query_Recordset1 = ("SELECT pupils.pupilID, pupils.UPN,
    pupils.forename, pupils.surname FROM pupils WHERE UPN = '" .
    $_SESSION['UPN'] . "'");
    The recordset returns nothing- the dynamic table returns ony
    the column headings (both as headings and immediately under where
    you would expect the data to be).
    Can anyone help?
    Thanks

    On Wed, 17 Oct 2007 11:43:04 +0000 (UTC), "denman"
    <[email protected]> wrote:
    > I have set the session variable like this:
    $_SESSION['UPN'] = 'UPN' (UPN is
    >the name of the form textfield, also set as the username
    for logging in)
    Your code assigns the literal string UPN to the session
    variable. If
    it's coming from POSTed form data, you'd need to do it like:
    $_SESSION['UPN'] = $_POST['UPN'];
    Gary

  • PHP Session Variable

    When using the PHP variable $_SESSION['idk'], what is the significance to the string 'idk'?
    I have been playing around with a login script, and I have seen some people throw 'user_login' or 'login' or 'user' and I figured it was just a way of labeling it essentially. But then I happened across a post where someone was generating and using a random string with the Session variable.
    Does this string have to be different for every user logging into a website? If not, what is the purpose of generating a random string to use in conjunction with the Session variable?
    Maybe any insight into different uses of the Session variable would be helpful as well.
    Thanks!

    With this post we're launching a new feature in the community: a look at a few of the day's top stories or issues. Let us know what you think – and where in the community you'd like to find these topics on a daily basis.Browser woes – Chrome 44 was released yesterday, but a "feature" of the latest softwarebroke some WordPress pluginsand many plugin developers have released updates to fix the problem. Meanwhile, HP's Zero Day Initiative disclosedfour zero-day vulnerabilitiesin Internet Explorer."Pocket dialing" privacy – A federal appeals court in Ohio hasruledthat anyone who accidentally "pocketdials" someone loses their right to privacy because they "lack a reasonable expectation that their conversations would not be intercepted, which is a prerequisite for protection under Title III."Bloomberg explains the background of the caseand...

  • First php session transaction hangs.

    We set up Php with AS10g 9.0.4.1 about 8 mths ago.
    Each day the first user of our Php Application sees the first form ok, but when the user submits the first transaction by submitting the form, the form just hangs. The next user or same user starts another session of the Php application and all submissions work fine.
    It seems that it is always this first transaction in the morning that hangs.
    We know for sure there is NOT a connection problem to the database, as the developer has the application step out of the application if the database connection fails, and this has not happened.
    Our configuration is
    AS10g 9.0.4.1
    I downloaded I PHP 4.3.10 from www.php.net and set it up with the AS10g 9.0.4.1.
    Any ideas?

    As David_Powers said, check first, if sessions working correctly.
    I don't know how your database is designed but i would be surpriesed if the query fetchs a result. Email and MM_Username are the same?

  • Servlet/PHP Session Variables

    Hello Everyone,
    I am running an servlet that requires authentication. The authentication is done by a PHP program, while the heavy lifting is done by a servlet. How do I pass a session variable from my php to my servlet so that my servlet knows the user is allowed. I have tried
    Object done = session.getAttribute("loggedIn");
    with "loggedIn" being set by my php file, but done is always null. Any help is greatly appreciated especially if it is cookie free.
    Sincerely,
    Chem E

    You could consider the following solution: on click of the link, fire a specific Ajaxical request from the server where PHP runs to the server where Java runs to obtain an lengthy and unique key which expires within a few seconds, use JS+DOM to add that key as a query parameter to the link value and after opening the link let the Java side determine the key and handle accordingly.
    You only need to write code so that it is hack safe.

  • How do I use the Profile Manager to run multiple PHP sessions?

    I have a website that tracks the session and state of users as they traverse through the site. Several users can "work together" simultaneously. To test this cooperative functionality, I ran multiple Firefox profiles simultaneously on my computer, using Firefox's Profile Manager. After logging in as two users (one on each separate running Firefox instance), one of my Firefox instances still works, while the other one does not seem to track the session.
    How do I create and run multiple Firefox instances to allow me to test the functionality of such sites? I believe this worked a few months ago. Perhaps this is a new bug?
    I even tried running normal Firefox and Firefox Extended Support Release simultaneously, but I ran into the same error.

    Disregard the question. The solution has nothing to do with any "Firefox bug". Turns out that my session wasn't being managed properly. Or rather, I was accidentally deleting other users' information when new users logged in. So if I had user 1 and user 2, and user 2 logged in after user 1, some of user 1's information would be deleted, resulting in the errors.
    Oops; sorry about the false alarm. :)
    (Was hoping to retract the question, but it looks like others have a similar problem.)

  • Server sided php session cookies are being deleted only in firefox

    When I visit a site and log in to that site, after 5 seconds the session is already closed. This does not happen with any other browser, just with firefox.
    I have altered the privacy settings in firefox, so all cookies of this site are allowed, but the problem remains.

    Certain Firefox problems can be solved by performing a ''Clean reinstall''. This means you remove Firefox and any leftover program files and then reinstall Firefox. Please follow these steps one by one:
    #Download the latest Desktop version of Firefox from http://www.mozilla.org and save the setup file to your computer.
    #After the download finishes, close all Firefox windows (click Exit from the Firefox or File menu) and confirm all upcoming messages.
    #Now, uninstall Firefox by following the steps mentioned in the [[Uninstall Firefox from your computer#w_uninstall-firefox|Uninstall Firefox]] article.
    '''IMPORTANT:''' On Windows, the uninstaller has the option to remove your personal data and settings. Make sure that you do '''not''' check this option; otherwise all of your bookmarks, passwords, extensions, user customizations and other Firefox [[Profiles|user profile data]] will be removed from your computer.
    After uninstalling Firefox on Windows, delete the "Mozilla Firefox" program folder, located by default in one of these locations:
    * '''(On 32-bit Windows)''' ''C:\Program Files\Mozilla Firefox''
    * '''(On 64-bit Windows)''' ''C:\Program Files (x86)\Mozilla Firefox''
    #Go to the Windows Start menu and click on "Computer".
    #In the Explorer window that opens, double click Local Disk (C:) to open the C:\ drive.
    #Find the "Program Files (x86)" folder or "Program Files" folder.
    #* On 32-bit Windows, double-click the '''Program Files''' folder to open it.
    #* On 64-bit Windows, you will see a "Program Files (x86)" folder AND a "Program Files" folder. Open the '''Program Files (x86)''' folder.
    #Look for a '''Mozilla Firefox''' folder. If you find one, right-click it and select ''Delete'' and confirm that you want to move the folder to the Recycle Bin.
    Now, go ahead and reinstall Firefox:
    #Double-click the downloaded installation file and go through the steps of the installation wizard.
    #Once the wizard is finished, choose to directly open Firefox after clicking the Finish button.
    Please report back to see if this helped you!

  • Flash builder and php session management/login

    I've secured pages with cflogin using coldfusion but is there a comparible function in PHP?  I'm able to connect to a php/mysql DB but how do I lock those functions down with a login/password style security?
    Thanks

    Hi,
    I think this article contains what you are looking for.
    http://sudhirmanjunath.blogspot.com/2009/10/how-to-set-basic-authentication-for-php.html
    Please write back if you need any further clarifications.
    Thanks,
    Sudhir

Maybe you are looking for