Jump to content



Photo

new session after every refresh?


  • Please log in to reply
3 replies to this topic

#1 b3njo

b3njo

    OrangBiasa

  • Joined: 01-December 01

Posted 03 November 2004 - 04:04

hi all, is it possible to have a new session each time a user refresh the page? here's the code i'm using right now, but it doesnt work:

<?php 
session_start();
$_SESSION['sid'] = session_id();
?>

html :
<body>
<?php echo $_SESSION['sid']; 
unset($_SESSION['sid']);
?>

</body>

What is wrong with my code? :blush:


#2 Endoscient

Endoscient

    Neowinian

  • Joined: 04-November 01

Posted 03 November 2004 - 04:31

the problem with your code is that you are just unsetting a normal variable that u happen to set as the session id. I dont get what you are trying to do with this anyway... that defeats the point of a session.

if u want a new session id jsut do this
<?php

session_regenerate_id();

?>


#3 chuayw2000

chuayw2000

    Ace's brother

  • Joined: 12-July 03
  • Location: Singapore

Posted 03 November 2004 - 06:45

Did u output anything before session_start? The script needs to send a cookie to initialise the session.

#4 Ricky Baby

Ricky Baby

    Yurp

  • Joined: 01-July 02

Posted 04 November 2004 - 14:16

you kinda defeating the whole point of sessions lol - just overwrite them to NULL