flit Posted April 13, 2008 Share Posted April 13, 2008 Hi there, I have the following links on a page: <a href="7.php<?php session_start(); $_SESSION['id']=1;?>">Test 1</a> <br> <a href="7.php<?php session_start(); $_SESSION['id']=2;?>">Test 2</a> <br> <a href="7.php<?php session_start(); $_SESSION['id']=3;?>">Test 3</a> <br> <a href="7.php<?php session_start(); $_SESSION['id']=8;?>">Test 8</a> When I click the first link [test 1], the value 8 is written in the session file and not the value 1 When I click the second link I want the value 2 to be added into the session file. I want my session file to look like this: id|i:1,2; Can somebody tell me what I am doing wrong?? Link to comment https://forums.phpfreaks.com/topic/100916-problem-with-php-sessions/ Share on other sites More sharing options...
dezkit Posted April 13, 2008 Share Posted April 13, 2008 i don't know but.... <a href="7.php?id=<?php session_start(); $_SESSION['id']=1; ?>">Test 1</a> Link to comment https://forums.phpfreaks.com/topic/100916-problem-with-php-sessions/#findComment-516061 Share on other sites More sharing options...
flit Posted April 13, 2008 Author Share Posted April 13, 2008 I used to use <a href='"7.php?action=add&id=1">Test 1</a> But I don't want anything displayed into my web browser after 7.php Link to comment https://forums.phpfreaks.com/topic/100916-problem-with-php-sessions/#findComment-516064 Share on other sites More sharing options...
dezkit Posted April 13, 2008 Share Posted April 13, 2008 thats impossible imo Link to comment https://forums.phpfreaks.com/topic/100916-problem-with-php-sessions/#findComment-516065 Share on other sites More sharing options...
wildteen88 Posted April 13, 2008 Share Posted April 13, 2008 You only need to call session_start() only once . You don't call it everytime you want to use a session variable. You should call session_start() before any output. If you have any form of output you'll get either a blank page or an "header already sent" error message. If you don't want PHP to continue the script at a certain pioint use die(); or exit; Link to comment https://forums.phpfreaks.com/topic/100916-problem-with-php-sessions/#findComment-516068 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.