Jump to content

session expires immediately


divinecoder

Recommended Posts

Hi Friends,

 

Thanks for your initiatives to help me.

 

Here is my code:

<?
ob_start();
session_start();

if ($_GET['x']!="" && $_SESSION['custKey']=="")
{
$ky=$_GET['x'];
$_SESSION['custKey']=$ky;
}

if ($_GET['page'] == "login"){
include("login.php");
}
elseif ( $_GET['page'] == "cust_main" ) { 
include("custmain.php"); 
}

/*custmain.php*/
if (isset($_SESSION['custKey']))
	$cust_key=$_SESSION['custKey'];
else
	header("location:index.php?page=login&redirect=cust_main");


 

The above code works if i have the url as:

www.mydon.com/index.php?page=cust_main&x=5

 

immidiately after the above url is run if i remove x=5 and use only  www.mydon.com/index.php?page=cust_main it redirects me to login page.

 

Please let me know if am not clear in explaining you.

 

Thanks

 

 

 

Link to comment
Share on other sites

I checked php info, it seems to be fine. THats why confused.

 

session
Session Support 	enabled
Registered save handlers 	files user sqlite
Registered serializer handlers 	php php_binary wddx

Directive	Local Value	Master Value
session.auto_start	Off	Off
session.bug_compat_42	Off	Off
session.bug_compat_warn	On	On
session.cache_expire	180	180
session.cache_limiter	nocache	nocache
session.cookie_domain	no value	no value
session.cookie_lifetime	0	0
session.cookie_path	/	/
session.cookie_secure	Off	Off
session.entropy_file	no value	no value
session.entropy_length	0	0
session.gc_divisor	100	100
session.gc_maxlifetime	1440	1440
session.gc_probability	1	1
session.hash_bits_per_character	4	4
session.hash_function	0	0
session.name	PHPSESSID	PHPSESSID
session.referer_check	no value	no value
session.save_handler	files	files
session.save_path	/var/php_sessions	/var/php_sessions
session.serialize_handler	php	php
session.use_cookies	On	On
session.use_only_cookies	Off	Off
session.use_trans_sid	1	1

Link to comment
Share on other sites

Well you need to view the page more than once, like take off your x=5 part. The first time the session will be empty, so there are no values. So if you add it at the bottom too, you should see the change, the session variables got assigned.

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.