LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 08-14-2004, 10:03 AM   #1
rkwhited
LQ Newbie
 
Registered: Mar 2004
Location: california
Distribution: red hat
Posts: 7

Rep: Reputation: 0
Cookie Sharing Between CGI generated HTML pages and standard HTML pages


I am putting together a website that has stock HTML pages but it also has pages that are totally generated by a CGI program on the server.

Cookies written on the client by pages generated by the CGI program are not seen by the stock HTML pages.

What is a good way to work around this?

rkwhited
 
Old 08-14-2004, 10:22 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
HTML pages aren't capable of doing anything with cookies so you will need to use some other language to handle the cookies - can you post a copy of the bit of code that you don't think is working?
 
Old 08-14-2004, 01:32 PM   #3
rkwhited
LQ Newbie
 
Registered: Mar 2004
Location: california
Distribution: red hat
Posts: 7

Original Poster
Rep: Reputation: 0
David,

My bad. I am using the javascript/html DOM feature 'document.cookie' ... does that change your reply?

rkwhited
 
Old 08-14-2004, 03:31 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
There shouldn't be any problem with javascript accessing the same cookies as a perl/php script etc so long as they are all on the same domain.

I'm not sure what to suggest without seeing the code.
 
Old 08-14-2004, 05:47 PM   #5
rkwhited
LQ Newbie
 
Registered: Mar 2004
Location: california
Distribution: red hat
Posts: 7

Original Poster
Rep: Reputation: 0
The code is just simple, run of the mill "document.cookie = name + = + value + expires" type code. Same with the read.

But you mention domain. That is where the problem must be. The cgi-bin directory is where the CGI program generates new HTML pages, and the public directory where the static .html pages are located is one directory above the cgi-bin directory.

This fools the browser into thinking it is a different domain evidently ... the cookie code works ok when offline not using the CGI program. But when the code is moved to the server this changes things.

I verified this by reading the cookie directory and the CGI program cookies are written to a different cookie ...

so ... your mention of the domain is a good suspicion ... making the domain the same is looking like the central issue ... and I am not sure that is feasible ...

rkwhited
 
Old 08-15-2004, 07:39 AM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
Ah - I think I may see your problem. Did you remember to set "path=/" in your cookie? if not then it will only be available to the path where the cookie was created.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I watch html pages in text mode (e.g. with the help of Emacs, etc)? kornerr Linux - General 6 03-01-2005 10:30 AM
saving html pages with images in Konqueror nykysle Linux - General 1 12-19-2004 08:20 AM
Print text file in html pages ariana Programming 1 11-12-2004 03:18 PM
Mails, Attachments, Html Pages Corrupted basbosco Linux - Security 1 03-03-2004 01:53 PM
loading html pages with php BaudRacer Programming 3 12-03-2003 08:34 AM


All times are GMT -5. The time now is 08:55 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration