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
https://forums.phpfreaks.com/topic/61725-question-about-unsetsession/
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>';
      }

?>

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'].'

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.