Jump to content

Question about unset($session)


jim.davidson

Recommended Posts

This might be the stupidist question asked on this forum, but here goes. I am teaching myself php. The book I'm reading says that if you issue the command unset($session) it clears the present session and prevents further sessions from being stored.

 

Like I said I'm self taught, but does that mean that if on the server that my hosting company assigned me to, someone else issued unset($session) then I wouldn't be able to store info to a session on that server?

 

The reason I ask this is that I'm trying to pass session variable to another page and it works on my localhost testing but not on the live server.

 

Thanks

 

Link to comment
Share on other sites

Sessions on other sites on the same server will not affect yours...no. And as long as you're learning, there are no stupid questions.

 

Here's a simple session test I wrote. Try it on your server and see if sessions are working....save it as 'test.php' or something and run it

 

<?php

  //Checks to see if session information is being saved/set correctly//

    if(isset($_GET['checksess']) && $_GET['checksess'] == 1) {

      session_start();

      $current_time = date("h:i:s A", time());

      echo'
      <div>This sessions started at: '.$_SESSION['start'].'...It is now '.$current_time.'</div><br />
      <div><a href="'.$_SERVER['REQUEST_URI'].'" target="_parent">Refresh!</a></div>';
    }

      else 
      {
        session_start();
        $_SESSION['start'] = date("h:i:s A", time());

        echo'Click here to check the session -> <a href="'.$_SERVER['PHP_SELF'].'?checksess=1" target="_parent">Click Me</a>';
      }

?>

Link to comment
Share on other sites

Thank you very much, I did'nt think so, wouldn't have made a sense to share if it did.

 

I tried the test program and is it suppose to go to my home page when you click refresh? That's where it went.

 

INteresting. It shouldn't, no. Try changing.....

 

'.$_SERVER['REQUEST_URI'].'

 

To....

 

?'.$_SERVER['QUERY_STRING'].'

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.